From Age of Empires 4 Modding

Localization with multiple script files and UI localization.

Simple mods should have no problem with using localization string ID directly:

my_string = "$MOD_ID:LOC_STR_ID"

Through once mod grows larger (multiple files) it might no longer work as expected. In that case you can use

my_string = Loc_FormatText("$MOD_ID:LOC_STR_ID")

For localizing xaml UI you will have to use DataContext to hold text and format it.

_mod.data_context.localizedHeader = Loc_FormatText("$MOD_ID:LOC_STR_ID")

<TextBlock Text="{Binding [localizedHeader] }" />