You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/08-Plugins/10-i18n.md
+65Lines changed: 65 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -572,6 +572,71 @@ import { admin } from '../index';
572
572
}
573
573
```
574
574
575
+
## Different scripts (writing systems) / regions / variants / dialects
576
+
577
+
### Scripts (Writing systems)
578
+
579
+
For some languages you may want translations in a specific, non-default script (or want the choice to be deterministic).
580
+
581
+
For example, Serbian (`sr`) is written in both Cyrillic and Latin scripts. If you use only `sr`, an LLM may pick a script inconsistently (or default to Cyrillic). To force a particular script, use `translateLangAsBCP47Code`:
582
+
583
+
```ts
584
+
translateLangAsBCP47Code: { sr: 'sr-Latn' }
585
+
```
586
+
587
+
Alternatively, you can or course use the script-tagged BCP47 code directly in `supportedLanguages`:
588
+
589
+
```diff
590
+
---supportedLanguages: ['en', 'sr']
591
+
+++supportedLanguages: ['en', 'sr-Latn']
592
+
```
593
+
594
+
However, in this case `sr-Latn` becomes the language identifier everywhere. For example if you expose language codes to an external app (e.g., in URLs or subdomains), you may end up with URLs like `https://my.site/sr-Latn/my-page`, which is sometimes undesirable. You can work around this by remapping `sr-Latn ↔ sr` in the external system, but we generally recommend `translateLangAsBCP47Code` as the dedicated, internal way to keep a clean ISO 639-1 code while translating as a specific BCP47 tag.
595
+
596
+
Ifyouwanttosupportbothscriptsexplicitly, include both in `supportedLanguages`:
597
+
598
+
```ts
599
+
supportedLanguages: ['en', 'sr-Latn', 'sr-Cyrl']
600
+
```
601
+
602
+
### Dialectsandnationalstandards
603
+
604
+
EuropeanPortugueseandBrazilianPortuguesediffer, so it’s common to use BCP47 region subtags to distinguish them.
605
+
606
+
To support both:
607
+
608
+
```ts
609
+
supportedLanguages: ['en', 'pt-BR', 'pt-PT']
610
+
```
611
+
612
+
Ifyouonlywantoneversion (e.g. BrazilianPortuguese) butstillwanttokeepaclean`pt`codeinyourAPI/URLs, use `translateLangAsBCP47Code`:
Morerarely, you may need a specific language variant. For example, British English typically uses standard BrE spelling, but the Oxford English Dictionary variant (OED) differs in some cases:
624
+
625
+
| Standard BrE | Oxford (OED) |
626
+
| --- | --- |
627
+
| colour | colour |
628
+
| organise | organize |
629
+
| realise | realize |
630
+
631
+
You can use `translateLangAsBCP47Code` to request a specific variant:
632
+
633
+
```ts
634
+
supportedLanguages: ['en']
635
+
translateLangAsBCP47Code: { en: 'en-GB-oed' }
636
+
```
637
+
638
+
As any BCP47 tag it is also supported in `supportedLanguages` directly, but again this will make the full tag (e.g., `en-GB-oed`) appear in your API/URLs external systems unless you remap it externally.
639
+
575
640
## Translating external application
576
641
577
642
You can use this module not only to translate admin area of your application but also to translate other parts like SEO-facing or user-facing services.
0 commit comments