mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-21 23:03:07 +00:00
Don't use external formatting for l10n strings
This commit is contained in:
parent
a6097d06b6
commit
8fcad02f5d
11 changed files with 29 additions and 26 deletions
|
|
@ -124,10 +124,8 @@ namespace
|
|||
return;
|
||||
}
|
||||
|
||||
std::string messageFormat
|
||||
= MWBase::Environment::get().getL10nManager()->getMessage("OMWEngine", "ScreenshotMade");
|
||||
|
||||
std::string message = Misc::StringUtils::format(messageFormat, filePath);
|
||||
auto l10n = MWBase::Environment::get().getL10nManager()->getContext("OMWEngine");
|
||||
std::string message = l10n->formatMessage("ScreenshotMade", { "file" }, { L10n::toUnicode(filePath) });
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->scheduleMessageBox(
|
||||
std::move(message), MWGui::ShowInDialogueMode_Never);
|
||||
|
|
|
|||
|
|
@ -148,11 +148,8 @@ void MWState::StateManager::askLoadRecent()
|
|||
std::vector<std::string> buttons;
|
||||
buttons.emplace_back("#{Interface:Yes}");
|
||||
buttons.emplace_back("#{Interface:No}");
|
||||
std::string message
|
||||
= MWBase::Environment::get().getL10nManager()->getMessage("OMWEngine", "AskLoadLastSave");
|
||||
std::string_view tag = "%s";
|
||||
size_t pos = message.find(tag);
|
||||
message.replace(pos, tag.length(), saveName);
|
||||
auto l10n = MWBase::Environment::get().getL10nManager()->getContext("OMWEngine");
|
||||
std::string message = l10n->formatMessage("AskLoadLastSave", { "save" }, { L10n::toUnicode(saveName) });
|
||||
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(message, buttons);
|
||||
mAskLoadRecent = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,8 +48,7 @@ namespace L10n
|
|||
std::optional<icu::MessageFormat> parseMessageFormat(
|
||||
const icu::Locale& lang, std::string_view key, std::string_view value, std::string_view locale)
|
||||
{
|
||||
icu::UnicodeString pattern
|
||||
= icu::UnicodeString::fromUTF8(icu::StringPiece(value.data(), static_cast<std::int32_t>(value.size())));
|
||||
icu::UnicodeString pattern = toUnicode(value);
|
||||
icu::ErrorCode status;
|
||||
UParseError parseError;
|
||||
icu::MessageFormat message(pattern, lang, parseError, status);
|
||||
|
|
@ -308,8 +307,7 @@ namespace L10n
|
|||
std::vector<icu::Formattable> argValues;
|
||||
for (auto& [k, v] : args)
|
||||
{
|
||||
argNames.push_back(
|
||||
icu::UnicodeString::fromUTF8(icu::StringPiece(k.data(), static_cast<std::int32_t>(k.size()))));
|
||||
argNames.push_back(toUnicode(k));
|
||||
argValues.push_back(v);
|
||||
}
|
||||
return formatMessage(key, argNames, argValues);
|
||||
|
|
@ -338,4 +336,10 @@ namespace L10n
|
|||
return std::string(key);
|
||||
return formatArgs(*defaultMessage, key, argNames, args);
|
||||
}
|
||||
|
||||
icu::UnicodeString toUnicode(std::string_view value)
|
||||
{
|
||||
icu::StringPiece piece(value.data(), static_cast<std::int32_t>(value.size()));
|
||||
return icu::UnicodeString::fromUTF8(piece);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ namespace L10n
|
|||
const icu::MessageFormat* findMessage(std::string_view key, std::string_view localeName) const;
|
||||
};
|
||||
|
||||
icu::UnicodeString toUnicode(std::string_view value);
|
||||
}
|
||||
|
||||
#endif // COMPONENTS_L10N_MESSAGEBUNDLES_H
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
AskLoadLastSave: "sLoadLastSaveMsg"
|
||||
AskLoadLastSave:
|
||||
pattern: "{gmst:sLoadLastSaveMsg}"
|
||||
variables:
|
||||
- ["save"]
|
||||
AudioEffects: "sEffects"
|
||||
AudioFootsteps: "sFootsteps"
|
||||
AudioMaster: "sMaster"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ PhysicsProfiler: "Physik-Profiler"
|
|||
|
||||
# Messages
|
||||
|
||||
AskLoadLastSave: "Der aktuellste Spielstand ist '%s'. Soll er geladen werden?"
|
||||
AskLoadLastSave: "Der aktuellste Spielstand ist '{save}'. Soll er geladen werden?"
|
||||
BuildingNavigationMesh: "Erstelle Navigationsgitter..."
|
||||
InitializingData: "Initialisiere Daten..."
|
||||
LoadingExterior: "Lade Bereich..."
|
||||
|
|
@ -30,7 +30,7 @@ QuitGameConfirmation: "Spiel verlassen?"
|
|||
SaveGameDenied: "Das Spiel kann gerade nicht gespeichert werden!"
|
||||
SavingInProgress: "Speichere Spiel..."
|
||||
ScreenshotFailed: "Speichern des Screenshots fehlgeschlagen!"
|
||||
ScreenshotMade: "%s wurde gespeichert."
|
||||
ScreenshotMade: "{file} wurde gespeichert."
|
||||
|
||||
|
||||
# Save game menu
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ PhysicsProfiler: "Physics Profiler"
|
|||
|
||||
# Messages
|
||||
|
||||
AskLoadLastSave: "The most recent save is '%s'. Do you want to load it?"
|
||||
AskLoadLastSave: "The most recent save is '{save}'. Do you want to load it?"
|
||||
BuildingNavigationMesh: "Building Navigation Mesh"
|
||||
InitializingData: "Initializing Data..."
|
||||
LoadingExterior: "Loading Area"
|
||||
|
|
@ -30,7 +30,7 @@ QuitGameConfirmation: "Quit the game?"
|
|||
SaveGameDenied: "The game cannot be saved right now."
|
||||
SavingInProgress: "Saving..."
|
||||
ScreenshotFailed: "Failed to save screenshot"
|
||||
ScreenshotMade: "%s has been saved"
|
||||
ScreenshotMade: "{file} has been saved"
|
||||
|
||||
|
||||
# Save game menu
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ PhysicsProfiler: "Profileur des performances de la physique"
|
|||
# Messages
|
||||
|
||||
BuildingNavigationMesh: "Construction du mesh de navigation"
|
||||
AskLoadLastSave: "La sauvegarde la plus récente est '%s'. Voulez-vous la charger ?"
|
||||
AskLoadLastSave: "La sauvegarde la plus récente est '{save}'. Voulez-vous la charger ?"
|
||||
InitializingData: "Initialisation des données..."
|
||||
LoadingExterior: "Chargement de la zone de jeu"
|
||||
LoadingFailed: "Échec du chargement de la sauvegarde"
|
||||
|
|
@ -30,7 +30,7 @@ QuitGameConfirmation: "Quitter la partie ?"
|
|||
SaveGameDenied: "Sauvegarde impossible"
|
||||
SavingInProgress: "Sauvegarde en cours..."
|
||||
ScreenshotFailed: "Échec de la sauvegarde de la capture d'écran"
|
||||
ScreenshotMade: "Capture d'écran %s sauvegardée"
|
||||
ScreenshotMade: "Capture d'écran {file} sauvegardée"
|
||||
|
||||
|
||||
# Save game menu
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ PhysicsProfiler: "Profilowanie fizyki"
|
|||
|
||||
# Messages
|
||||
|
||||
AskLoadLastSave: "Ostatni zapis to '%s'. Czy chcesz go wczytać?"
|
||||
AskLoadLastSave: "Ostatni zapis to '{save}'. Czy chcesz go wczytać?"
|
||||
BuildingNavigationMesh: "Tworzenie siatki nawigacyjnej"
|
||||
InitializingData: "Inicjalizacja..."
|
||||
LoadingExterior: "Wczytywanie obszaru zewnętrznego"
|
||||
|
|
@ -30,7 +30,7 @@ QuitGameConfirmation: "Wyjść z gry?"
|
|||
SaveGameDenied: "Gra nie może być teraz zapisana."
|
||||
SavingInProgress: "Zapisywanie..."
|
||||
ScreenshotFailed: "Nie udało się zapisać zrzutu ekranu"
|
||||
ScreenshotMade: "%s został zapisany"
|
||||
ScreenshotMade: "{file} został zapisany"
|
||||
|
||||
|
||||
# Save game menu
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ PhysicsProfiler: "Профилировщик физики"
|
|||
|
||||
# Messages
|
||||
|
||||
AskLoadLastSave: "Последнее сохранение - '%s'. Загрузить?"
|
||||
AskLoadLastSave: "Последнее сохранение - '{save}'. Загрузить?"
|
||||
BuildingNavigationMesh: "Построение навигационной сетки"
|
||||
InitializingData: "Загрузка..."
|
||||
LoadingExterior: "Загрузка области"
|
||||
|
|
@ -30,7 +30,7 @@ QuitGameConfirmation: "Выйти из игры?"
|
|||
SaveGameDenied: "В данный момент игру нельзя сохранить."
|
||||
SavingInProgress: "Сохранение..."
|
||||
ScreenshotFailed: "Не удалось создать снимок экрана"
|
||||
ScreenshotMade: "Создан снимок экрана %s"
|
||||
ScreenshotMade: "Создан снимок экрана {file}"
|
||||
|
||||
|
||||
# Save game menu
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ PhysicsProfiler: "Fysikprofilerare"
|
|||
|
||||
# Messages
|
||||
|
||||
AskLoadLastSave: "Den senaste sparfilen är '%s'. Vill du ladda den?"
|
||||
AskLoadLastSave: "Den senaste sparfilen är '{save}'. Vill du ladda den?"
|
||||
BuildingNavigationMesh: "Bygger navigeringsmesh"
|
||||
InitializingData: "Initialiserar data..."
|
||||
LoadingExterior: "Laddar område"
|
||||
|
|
@ -30,7 +30,7 @@ QuitGameConfirmation: "Avsluta spelet?"
|
|||
SaveGameDenied: "Spelet kan inte sparas just nu."
|
||||
SavingInProgress: "Sparar..."
|
||||
ScreenshotFailed: "Misslyckades att spara skärmdump"
|
||||
ScreenshotMade: "%s har sparats"
|
||||
ScreenshotMade: "{file} har sparats"
|
||||
|
||||
|
||||
# Save game menu
|
||||
|
|
|
|||
Loading…
Reference in a new issue