Build options
@ember-intl/v1-compat and @ember-intl/vite support a few options for how translations are loaded and merged.
For v1 apps, create config/ember-intl.js (CJS). The file default-exports a function, which returns the build options as an object.
module.exports = function (/* environment */) {
return {
fallbackLocale: 'en-us',
};
};2
3
4
5
For v2 apps, create ember-intl.config.{js,mjs} (ESM). The file default-exports an object, which may include addonPaths, buildOptions, and lintRules.
export default {
buildOptions: {
fallbackLocale: 'en-us',
},
};2
3
4
5
addonPaths
For v2 apps, to include an addon's translations, specify the relative path to the addon's root.
export default {
addonPaths: ['node_modules/my-v1-addon', 'node_modules/my-v2-addon'],
};2
3
NOTE
If multiple addons define the same key, the last appearing addon's translation wins. (This isn't possible with @ember-intl/v1-compat.)
The app's translation always takes precedence over an addon's.
buildOptions
Here are the options' names and default values.
type ConfigBuildOptions = {
fallbackLocale: string | undefined;
inputPath: string;
publicOnly: boolean; // Only for `@ember-intl/v1-compat`
wrapTranslationsWithNamespace: boolean;
};
const defaultBuildOptions: ConfigBuildOptions = {
fallbackLocale: undefined,
inputPath: 'translations',
publicOnly: false, // Only for `@ember-intl/v1-compat`
wrapTranslationsWithNamespace: false,
};2
3
4
5
6
7
8
9
10
11
12
13
fallbackLocale
Copy the fallback locale's translations to all other locales as a fallback strategy.
{
fallbackLocale: 'en-us',
}2
3
inputPath
Where translations live relative to the project root.
For example, if an app has stored them in public/assets/translations:
{
inputPath: 'public/assets/translations',
}2
3
If a v1 addon's dummy app provides its own translations (these aren't published):
/* tests/dummy/config/ember-intl.js */
{
inputPath: 'tests/dummy/translations',
}2
3
4
publicOnly
Prevents the translations from being bundled with the application code. This enables lazily loading the translations.
{
publicOnly: true,
}2
3
For more information, see Lazy-loading translations.
wrapTranslationsWithNamespace
Derive the key's namespace from the folder path. This enables storing translations in subfolders whose structure closely resembles that of app/components and app/templates.
{
wrapTranslationsWithNamespace: true,
}2
3
For more information, see Organizing translations.