How to import static translation json for localization in 2022.06

Question on behalf of @jeanpierre-golden-knoll:

Hi, sorry I don’t understand the documentation on migration localization

LocalizerChainServices are no longer necessary since A12 libraries do not need to do any chaining of different localization approaches internally. On A12 consumer side, a chaining can still be achieved by simply implementing a custom Localizer function that can delegate to different localization approaches as required.

What are we supposed to do now to import a static translation json ?

Answer on behalf of @theodossios-steep-crest:

const defaultLocalizer = defaultLocalizerFactory({
        locale,
        dataFormats: defaultDataFormats(locale),
        translationSource: L10N_RESOURCES,
    }); 

L10N_RESOURCES is the static json

Reply on behalf of @jeanpierre-golden-knoll:

And L10N_RESOURCES is a plain key value object? And which method should I pass this default localizer to?

Answer on behalf of @theodossios-steep-crest:

Yes, the static json L10N_RESOURCES is a hierarchical one of type LocalizationTreeMap. So not the one you are used to, it has to be in a certain structure.

By method to pass this default localizer to, I think you might mean this:

export function localizer(...localizable: Localizable[]): string {
    const locale = {country: "DE", language: "de"};
    const defaultLocalizer = defaultLocalizerFactory({
        locale,
        dataFormats: defaultDataFormats(locale),
        translationSource: L10N_RESOURCES,
    });
    return defaultLocalizer(...localizable);
}