localization.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package basics
  2. import (
  3. "path"
  4. "github.com/qor5/docs/docsrc/examples/example_basics"
  5. "github.com/qor5/docs/docsrc/generated"
  6. "github.com/qor5/docs/docsrc/utils"
  7. "github.com/theplant/docgo"
  8. "github.com/theplant/docgo/ch"
  9. )
  10. var L10n = docgo.Doc(
  11. docgo.Markdown(`
  12. L10n gives your models the ability to localize for different Locales.
  13. It can be a catalyst for the adaptation of a product, application, or document content to meet the language, cultural, and other requirements of a specific target market.
  14. `),
  15. docgo.Markdown(`
  16. ## Define a struct
  17. Define a struct that requires embed ~l10n.Locale~.
  18. Also this struct must implement ~PrimarySlug() string~ and ~PrimaryColumnValuesBySlug(slug string) map[string]string~.
  19. `),
  20. ch.Code(generated.L10nModelExample).Language("go"),
  21. docgo.Markdown(`
  22. ## Init a l10n builder
  23. Register locales here.
  24. You can use ~GetSupportLocaleCodesFromRequestFunc~ to determine who can use which locales.
  25. `),
  26. ch.Code(generated.L10nBuilderExample).Language("go"),
  27. docgo.Markdown(`
  28. ## Configure the model builder
  29. Use ~l10n_view.Configure()~ func to configure l10n view.
  30. The ~Switch Locale~ ui will appear below the ~Brand~.
  31. The ~Localize~ ui will appear in the ~RowMenuItem~ under the ~Edit~ and the ~Delete~.
  32. ~Localize~ button is used to copy a piece of data from the current locale to the other locales.
  33. `),
  34. ch.Code(generated.L10nConfigureExample).Language("go"),
  35. docgo.Markdown(`
  36. ## Full Example
  37. `),
  38. ch.Code(generated.L10nFullExample).Language("go"),
  39. utils.Demo(
  40. "L10n",
  41. path.Join(example_basics.LocalizationExamplePath, "/l10n-models"),
  42. "example_basics/localization.go",
  43. ),
  44. ).Slug("basics/l10n").Title("Localization")