Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 1.49 KB

localization.md

File metadata and controls

27 lines (18 loc) · 1.49 KB

Localization

icsend is localized in over 50 languages. We use the fluent library and store our translations in FTL files in public/locales/. en-US is our base language.

Process

Strings are added or removed from [public/locales/en-US/send.ftl] as needed. Strings MUST NOT be changed after they've been commited and pushed to master. Changing a string requires creating a new ID with a new name (preferably descriptive instead of incremented) and deletion of the obsolete ID. It's often useful to add a comment above the string with info about how and where the string is used.

Activation

The development environment includes all locales in public/locales via the L10N_DEV environment variable. Production uses package.json as the list of locales to use. Once a locale has enough string coverage it should be added to package.json.

Code

In app/ we use the state.translate() function to translate strings to the best matching language base on the user's Accept-Language header. It's a wrapper around fluent's FluentBundle.format. It works the same for both server and client side rendering.

Examples

// simple string
const finishedString = state.translate('downloadFinish')
// with parameters
const progressString = state.translate('downloadingPageProgress', {
  filename: state.fileInfo.name,
  size: bytes(state.fileInfo.size)
})