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