Properly use system language when language is set to system language, add missing translations

This commit is contained in:
dec05eba
2026-02-01 03:08:45 +01:00
parent f3d6d8bc53
commit a31bfbe288
7 changed files with 23 additions and 22 deletions

View File

@@ -31,13 +31,6 @@ namespace gsr {
return "en";
}
std::string Translation::trim(const std::string& str) {
size_t start = str.find_first_not_of(" \t\r\n");
if (start == std::string::npos) return "";
size_t end = str.find_last_not_of(" \t\r\n");
return str.substr(start, end - start + 1);
}
void Translation::process_escapes(std::string& str) {
size_t pos = 0;
while ((pos = str.find("\\n", pos)) != std::string::npos) {
@@ -93,8 +86,6 @@ namespace gsr {
std::string line;
while (std::getline(file, line)) {
line = trim(line);
if (line.empty() || line[0] == '#') continue;
size_t eq_pos = line.find('=');
@@ -124,6 +115,9 @@ namespace gsr {
}
void Translation::init(const char* translations_directory, const char* initial_language) {
if(initial_language && initial_language[0] == '\0')
initial_language = nullptr;
this->translations_directory = translations_directory;
load_language(initial_language == nullptr ? get_system_language().c_str() : initial_language);

View File

@@ -528,6 +528,7 @@ namespace gsr {
language_combo_box_ptr = combo_box.get();
combo_box->add_item(TR("System language"), "");
combo_box->add_item("English", "en");
combo_box->add_item("Español", "es");
combo_box->add_item("Русский", "ru");
combo_box->add_item("Українська", "uk");
combo_box->on_selection_changed = [](const std::string&, const std::string &id) {

View File

@@ -1127,7 +1127,7 @@ namespace gsr {
std::unique_ptr<RadioButton> SettingsPage::create_start_replay_automatically() {
// TODO: Support kde plasma wayland and hyprland (same ones that support getting window title)
char fullscreen_text[256];
snprintf(fullscreen_text, sizeof(fullscreen_text), TR("Turn on replay when starting a fullscreen application%s"), gsr_info->system_info.display_server == DisplayServer::X11 ? "" : " (X11 applications only)");
snprintf(fullscreen_text, sizeof(fullscreen_text), TR("Turn on replay when starting a fullscreen application%s"), gsr_info->system_info.display_server == DisplayServer::X11 ? "" : TR(" (X11 applications only)"));
auto radiobutton = std::make_unique<RadioButton>(&get_theme().body_font, RadioButton::Orientation::VERTICAL);
radiobutton->add_item(TR("Don't turn on replay automatically"), "dont_turn_on_automatically");
@@ -1140,7 +1140,7 @@ namespace gsr {
std::unique_ptr<CheckBox> SettingsPage::create_save_replay_in_game_folder() {
char text[256];
snprintf(text, sizeof(text), TR("Save video in a folder based on the focused applications name%s"), supports_window_title ? "" : " (X11 applications only)");
snprintf(text, sizeof(text), TR("Save video in a folder based on the focused applications name%s"), supports_window_title ? "" : TR(" (X11 applications only)"));
auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, text);
save_replay_in_game_folder_ptr = checkbox.get();
return checkbox;
@@ -1153,7 +1153,7 @@ namespace gsr {
}
std::unique_ptr<Label> SettingsPage::create_estimated_replay_file_size() {
auto label = std::make_unique<Label>(&get_theme().body_font, TR("Estimated video max file size in RAM: 57.60MB"), get_color_theme().text_color);
auto label = std::make_unique<Label>(&get_theme().body_font, "Estimated video max file size in RAM: 57.60MB", get_color_theme().text_color);
estimated_file_size_ptr = label.get();
return label;
}
@@ -1272,7 +1272,7 @@ namespace gsr {
general_list->add_widget(create_low_power_mode());
settings_list_ptr->add_widget(std::make_unique<Subsection>(TR("General"), std::move(general_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
settings_list_ptr->add_widget(std::make_unique<Subsection>(TR("Replay indicator"), create_indicator("replay"), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
settings_list_ptr->add_widget(std::make_unique<Subsection>(TR("Replay indicator"), create_indicator(TR("replay")), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
settings_list_ptr->add_widget(std::make_unique<Subsection>(TR("Autostart"), create_start_replay_automatically(), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
view_radio_button_ptr->on_selection_changed = [this](const std::string&, const std::string &id) {
@@ -1293,14 +1293,14 @@ namespace gsr {
std::unique_ptr<CheckBox> SettingsPage::create_save_recording_in_game_folder() {
char text[256];
snprintf(text, sizeof(text), TR("Save video in a folder based on the focused applications name%s"), supports_window_title ? "" : " (X11 applications only)");
snprintf(text, sizeof(text), TR("Save video in a folder based on the focused applications name%s"), supports_window_title ? "" : TR(" (X11 applications only)"));
auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, text);
save_recording_in_game_folder_ptr = checkbox.get();
return checkbox;
}
std::unique_ptr<Label> SettingsPage::create_estimated_record_file_size() {
auto label = std::make_unique<Label>(&get_theme().body_font, TR("Estimated video file size per minute (excluding audio): 345.60MB"), get_color_theme().text_color);
auto label = std::make_unique<Label>(&get_theme().body_font, "Estimated video file size per minute (excluding audio): 345.60MB", get_color_theme().text_color);
estimated_file_size_ptr = label.get();
return label;
}
@@ -1329,7 +1329,7 @@ namespace gsr {
general_list->add_widget(create_low_power_mode());
settings_list_ptr->add_widget(std::make_unique<Subsection>(TR("General"), std::move(general_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
settings_list_ptr->add_widget(std::make_unique<Subsection>(TR("Recording indicator"), create_indicator("recording"), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
settings_list_ptr->add_widget(std::make_unique<Subsection>(TR("Recording indicator"), create_indicator(TR("recording")), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
view_radio_button_ptr->on_selection_changed = [this](const std::string&, const std::string &id) {
view_changed(id == "advanced");
@@ -1462,7 +1462,7 @@ namespace gsr {
general_list->add_widget(create_low_power_mode());
settings_list_ptr->add_widget(std::make_unique<Subsection>(TR("General"), std::move(general_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
settings_list_ptr->add_widget(std::make_unique<Subsection>(TR("Streaming indicator"), create_indicator("streaming"), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
settings_list_ptr->add_widget(std::make_unique<Subsection>(TR("Streaming indicator"), create_indicator(TR("streaming")), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
streaming_service_box_ptr->on_selection_changed = [this](const std::string&, const std::string &id) {
const bool twitch_option = id == "twitch";

View File

@@ -264,7 +264,6 @@ Directory to save screenshots:=Directorio para guardar capturas de pantalla:
Image format:=Formato de imagen:
Save screenshot in a folder based on the focused applications name=Guardar captura de pantalla en un directorio basado en el nombre de la aplicación activa
Save screenshot in a folder based on the focused applications name (X11 applications only)=Guardar captura de pantalla en un directorio basado en el nombre de la aplicación activa (solo para aplicaciones X11)
Save screenshot to clipboard=Guardar captura de pantalla en el portapapeles
Save screenshot to clipboard (Not supported properly by Wayland)=Guardar captura de pantalla en el portapapeles (no admitido por Wayland)
@@ -317,6 +316,7 @@ Application: =Aplicación:
Custom...=Personalizado...
Save video in a folder based on the focused applications name%s=Guardar el vídeo en un directorio basado en el nombre de la aplicación activa
(X11 applications only)= (solo para aplicaciones X11)
Add audio track=Añadir pista de sonido
Add input device=Añadir dispositivo de entrada
@@ -373,6 +373,7 @@ Do not force the GPU to go into high performance mode when recording.\nMay affec
Show %s notifications=Mostrar notificación de %s
Show %s status with scroll lock led=Mostrar estado de %s con el LED de Bloq Despl
Recording indicator=Indicador de grabación
recording=grabando
Simple=Simple
Audio track #%d=Pista de sonido #%d
@@ -383,6 +384,7 @@ Estimated video file size per minute (excluding audio): %.2fMB=Tamaño estimado
# Replay settings
Directory to save replays:=Directorio para guardar las repeticiones:
Replay indicator=Indicador de repetición
replay=repetición
Turn on replay when starting a fullscreen application%s=Activar la repetición al iniciar una aplicación a pantalla completa%s
Autostart=Inicio automático
in RAM=en RAM
@@ -407,3 +409,4 @@ Stream URL:=URL de la transmisión
Stream key:=Clave de transmisión
Streaming info=Información de transmisión
Streaming indicator=Indicador de transmisión
streaming=transmisión

View File

@@ -267,7 +267,6 @@ Directory to save screenshots:=Каталог для сохранения сни
Image format:=Формат изображения:
Save screenshot in a folder based on the focused applications name=Сохранять снимок в папку по имени активного приложения
Save screenshot in a folder based on the focused applications name (X11 applications only)=Сохранять снимок в папку по имени активного приложения (только X11-приложения)
Save screenshot to clipboard=Сохранять снимок в буфер обмена
Save screenshot to clipboard (Not supported properly by Wayland)=Сохранять снимок в буфер обмена (в Wayland поддерживается некорректно)
@@ -319,6 +318,7 @@ Application: =Приложение:
Custom...=Другое...
Save video in a folder based on the focused applications name%s=Сохранять видео в папку по имени активного приложения%s
(X11 applications only)= (только X11-приложения)
Add audio track=Добавить аудиодорожку
Add input device=Добавить вход
@@ -408,4 +408,4 @@ Custom=Другое
Stream URL:=URL трансляции:
Stream key:=Ключ трансляции:
Streaming info=Информация о трансляции
Streaming indicator=Индикатор трансляции
Streaming indicator=Индикатор трансляции

View File

@@ -278,7 +278,6 @@ Directory to save screenshots:=
Image format:=
Save screenshot in a folder based on the focused applications name=
Save screenshot in a folder based on the focused applications name (X11 applications only)=
Save screenshot to clipboard=
Save screenshot to clipboard (Not supported properly by Wayland)=
@@ -331,6 +330,7 @@ Application: =
Custom...=
Save video in a folder based on the focused applications name%s=
(X11 applications only)=
Add audio track=
Add input device=
@@ -387,6 +387,7 @@ Do not force the GPU to go into high performance mode when recording.\nMay affec
Show %s notifications=
Show %s status with scroll lock led=
Recording indicator=
recording=
Simple=
Audio track #%d=
@@ -397,6 +398,7 @@ Estimated video file size per minute (excluding audio): %.2fMB=
# Replay settings
Directory to save replays:=
Replay indicator=
replay=
Turn on replay when starting a fullscreen application%s=
Autostart=
in RAM=
@@ -421,3 +423,4 @@ Stream URL:=
Stream key:=
Streaming info=
Streaming indicator=
streaming=

View File

@@ -266,7 +266,6 @@ Directory to save screenshots:=Каталог для збереження зні
Image format:=Формат зображення:
Save screenshot in a folder based on the focused applications name=Зберігати знімок у папку за ім'ям активної програми
Save screenshot in a folder based on the focused applications name (X11 applications only)=Зберігати знімок у папку за ім'ям активної програми (лише X11-програми)
Save screenshot to clipboard=Зберігати знімок до буфера обміну
Save screenshot to clipboard (Not supported properly by Wayland)=Зберігати знімок до буфера обміну (в Wayland підтримується некоректно)
@@ -317,6 +316,7 @@ Application: =Програма:
Custom...=Інше...
Save video in a folder based on the focused applications name%s=Зберігати відео у папку за ім'ям активної програми%s
(X11 applications only)= (лише X11-програми)
Add audio track=Додати аудіодоріжку
Add input device=Додати вхід