Skip to content

Latest commit

 

History

History
39 lines (22 loc) · 1.18 KB

File metadata and controls

39 lines (22 loc) · 1.18 KB

Rails i18n Webpack Plugin

Usage

Use as any other Webpack plugin or, if you're using Webpacker, append the plugin in your environment configuration:

// config/webpack/[env].js
const { environment } = require('@rails/webpacker');
const RailsI18nWebpackPlugin = require('@18f/identity-rails-i18n-webpack-plugin');

environment.plugins.append('RailsI18nWebpackPlugin', new RailsI18nWebpackPlugin());

Configuration

template

A Node.js util.format-formatted string, given an object of strings for each processed chunk.

Optional, defaults to '(window._locale_data = window._locale_data || []).push(%j);'.

configPath

The directory where locale YAML data is located. Defaults to config/locales relative to the project root.

Optional, defaults to path.resolve(process.cwd(), 'config/locales').

defaultLocale

The default locale for the application.

Optional, defaults to 'en'.

onMissingString

Callback invoked when a key cannot be found in locale data, optionally returning a string to return in its place.

Optional, defaults to () => {}.