Organizing translations
Translations are stored in /translations, either as a *.json or *.{yaml,yml} file.
my-app
├── app
└── translations
├── de-de.yaml
└── en-us.yamlAs the project grows, you will find the need to organize your translations. Here are a couple of ways to do so.
Nested keys
You can nest translation keys to depict relations.
components:
hello:
message: "Hallo, {name}!"
routes:
application:
title: Willkommen bei ember-intlNOTE
@ember-intl/v1-compat and @ember-intl/vite will flatten all keys. As a result, you can always write {{t "hello.message"}} in a template, whether keys are flat or nested in translation files.
Nested folders
You can create subfolders to split one locale file into multiple files.
my-app
├── app
└── translations
├── components
│ └── hello
│ ├── de-de.yaml
│ └── en-us.yaml
└── routes
└── application
├── de-de.yaml
└── en-us.yamlEach file should have a "namespace," an identifier that helps the translation keys, which are now separated, be still unique.
components.hello:
message: Hallo, {name}!routes.application:
title: Willkommen bei ember-intlAuto-namespace keys
In your configuration file, you can set wrapTranslationsWithNamespace to true to derive the namespace from the folder path.
export default {
buildOptions: {
wrapTranslationsWithNamespace: true,
},
};message: Hallo, {name}!title: Willkommen bei ember-intlNOTE
Spaces in a folder name are converted to underscores.