Documentation

 

Section groups

A section group defines the translation file of a lazy loaded module. The following JSON object is an example section group:

{
  group: 'shakespeare',
  path: '/assets/i18n/{ language }/{ section }.json',
  format: 'JSON',
  type: 'json',
  items: [ 'tragedies', 'comedies', { name: 'histories', alias: 'king' } ]
}

The section group has these properties:

group: string
The name of the translation file collection. It must be equal to the route, otherwise the group name has to be specifed in the route definition. Se below.
path: string
An optional path template of the translation files when it does not match the default template.
format: string
An optional value that defines the translation format of the group. It is used for custom format converters.
type: LoaderType
The type of the returned results expected by the downloader. The possible values are: 'json', 'text', 'blob' and 'arraybuffer'. The default value is 'json'. This parameter also is used for custom format converters.
items: Array< string | Section >
The list of the translation files. Each file is represented by a section definition, or a string in simple cases

A section group usually looks like that:

{ group: 'shakespeare', items: [ 'tragedies', 'comedies', 'histories' ] }

The translation group can be defined in the route when the route path differs from group name passing the name in the data object:

const routes: Routes = [
  ...
  {
    path: 'winter',
    loadChildren: () => import('./winter/winter.module').then(m => m.WinterModule),
    canLoad: [ LoadTranslationsGuard ],
    data: { translationGroup: 'frosty' }
  },
  ...
];

This way, the section group will be similar to:

{ group: 'frosty', items: [ 'december', 'january', 'february' ] }