translation (i18) / localisation (l10n) support #1591
amitu
started this conversation in
Ideas & RFCs
Replies: 1 comment
-
The default language should be decided by top-level package, if that language is not available then fallback to default of dependency package. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
lang
global<package-name>/lang
so any package can use any other package's lang stuff<package-name>/lang/<foo>
imports should also workChanges
i18n
tolang
, aslang
is auto import alias, and alsolang
handles bothi18n
andl10n
concerns.All Translations In Single Package
We are introducing one key
lang
, which must be the folder in which translation files are present, eg in this case we havemy-lang-files
folder, which should contain files likeen.ftd
(oren-us.ftd
,en-in.ftd
),hi.ftd
and so on.Each Translation In Individual Package
You can mix and match also:
In this setup, hi translation will be found in
lang-hi
module, and all other languages will be looked inmy-lang-files
folder (ifhi.ftd
is present inmy-lang-files
, then this would be a compilation error).All modules must match
Basically it is a compilation error if some key is present in one language file but not in another.
Localisation Helpers
ftd.lang.hi.number_to_string()
etc will localise a number to string.Language Detection / Activation
fastn
will honour a cookiefastn_lang
, with the language that user has currently selected. If cookie is missing we will look at request header and figure out the best language match.lang
"system"Any package that has language configured using
lang
keys, will have access tolang
auto imported module, which will point to the language module for the current request.Language Files Do Not Just Contain Strings
They can contain functions,
ftd.image-src
or even components.This Is Not Content Translation
This feature can be used for content translation, but it is largely meant for translating fastn powered user interfaces.
Content translation imposes additional requirements, like each language must have a searchable permanent URL. This scheme uses same URL for content, and uses cookie/accept-lang header to switch language. If you are writing a blog or a book and want it translated in multiple language, wait for the content translation feature.
Beta Was this translation helpful? Give feedback.
All reactions