loadTranslations static method
Load a real translation catalogue from disk for a widget test.
Reads <directory>/<locale>.json, flattens it with
JsonAssetLoader.flatten (the same rule the app's own loader uses),
and installs a TranslationLoader serving that map through
Translator.setLoader before awaiting Translator.load. trans()
resolves real catalogue strings afterward instead of rendering raw
dotted keys, which is what happens when no loader has ever run in a
widget test.
directory defaults to assets/lang, the app's own catalogue
location, so a test can point at a temp directory with a small
fixture json instead. Loading locale never requires a fallback-locale
file on disk: Translator.load only warns and falls back to an empty
map when the fallback catalogue fails to load
(translator.dart:_loadFallbackFor).
Implementation
static Future<void> loadTranslations(
String locale, {
String directory = 'assets/lang',
}) async {
Translator.instance.setLoader(_DirectoryTranslationLoader(directory));
await Translator.instance.load(Locale(locale));
}