-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
locales init #563
base: master
Are you sure you want to change the base?
locales init #563
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
*.slo | ||
*.lo | ||
*.o | ||
*.mo | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,6 +235,17 @@ else() | |
endif() | ||
endif() | ||
|
||
# i18n | ||
find_program (MSGFMT_EXECUTABLE msgfmt) | ||
find_program (MSGMERGE_EXECUTABLE msgmerge) | ||
find_program (XGETTEXT_EXECUTABLE xgettext) | ||
if(MSGFMT_EXECUTABLE AND MSGMERGE_EXECUTABLE AND XGETTEXT_EXECUTABLE) | ||
message (STATUS "Native language support enabled.") | ||
add_definitions(-DHAVE_GETTEXT) | ||
add_subdirectory (locale) | ||
endif() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add an |
||
add_definitions(-DINSTALLATION_PREFIX_DIR=\"${CMAKE_INSTALL_PREFIX}\") | ||
|
||
#------------------------------------------------------------------------------- | ||
# set up build directories | ||
set(dir ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
#ifdef WIN32 | ||
#include <Windows.h> | ||
#endif | ||
#include "LocaleES.h" | ||
|
||
#include <FreeImage.h> | ||
|
||
|
@@ -196,6 +197,28 @@ bool verifyHomeFolderExists() | |
return true; | ||
} | ||
|
||
void locales_init() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use tabs vs 2 spaces |
||
#ifdef HAVE_GETTEXT | ||
char* btd; | ||
char* cs; | ||
|
||
#define LOCALEDIR INSTALLATION_PREFIX_DIR "/share/locale" | ||
// local dir ; uncomment if you want to use locally compiled .mo files instead of .mo from the installation dir (present only after make install) | ||
//#define LOCALEDIR "./locale/lang" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RetroPie doesn't rely on |
||
|
||
setlocale (LC_MESSAGES, ""); | ||
textdomain("emulationstation"); | ||
if((btd=bindtextdomain("emulationstation", LOCALEDIR)) == NULL) { | ||
return; | ||
} | ||
|
||
cs = bind_textdomain_codeset("emulationstation", "UTF-8"); | ||
if(cs == NULL) { | ||
/* outch not enough memory, no real thing to do */ | ||
} | ||
#endif | ||
} | ||
|
||
// Returns true if everything is OK, | ||
bool loadSystemConfigFile(const char** errorString) | ||
{ | ||
|
@@ -287,6 +310,9 @@ int main(int argc, char* argv[]) | |
//always close the log on exit | ||
atexit(&onExit); | ||
|
||
// Set locale | ||
locales_init(); | ||
|
||
Window window; | ||
SystemScreenSaver screensaver(&window); | ||
PowerSaver::init(); | ||
|
@@ -311,9 +337,9 @@ int main(int argc, char* argv[]) | |
LOG(LogInfo) << " ARB_texture_non_power_of_two: " << (glExts.find("ARB_texture_non_power_of_two") != std::string::npos ? "ok" : "MISSING"); | ||
if(splashScreen) | ||
{ | ||
std::string progressText = "Loading..."; | ||
std::string progressText = _("Loading..."); | ||
if (splashScreenProgress) | ||
progressText = "Loading system config..."; | ||
progressText = _("Loading system config..."); | ||
window.renderLoadingScreen(progressText); | ||
} | ||
} | ||
|
@@ -333,7 +359,7 @@ int main(int argc, char* argv[]) | |
// we can't handle es_systems.cfg file problems inside ES itself, so display the error message then quit | ||
window.pushGui(new GuiMsgBox(&window, | ||
errorMsg, | ||
"QUIT", [] { | ||
_("QUIT"), [] { | ||
SDL_Event* quit = new SDL_Event(); | ||
quit->type = SDL_QUIT; | ||
SDL_PushEvent(quit); | ||
|
@@ -354,7 +380,7 @@ int main(int argc, char* argv[]) | |
ViewController::get()->preload(); | ||
|
||
if(splashScreen && splashScreenProgress) | ||
window.renderLoadingScreen("Done."); | ||
window.renderLoadingScreen(_("Done.")); | ||
|
||
//choose which GUI to open depending on if an input configuration already exists | ||
if(errorMsg == NULL) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
#include "Settings.h" | ||
#include "SystemData.h" | ||
#include "Window.h" | ||
#include "LocaleES.h" | ||
|
||
// buffer values for scrolling velocity (left, stopped, right) | ||
const int logoBuffersLeft[] = { -5, -2, -1 }; | ||
|
@@ -255,11 +256,14 @@ void SystemView::onCursorChanged(const CursorState& /*state*/) | |
// also change the text after we've fully faded out | ||
setAnimation(infoFadeOut, 0, [this, gameCount] { | ||
std::stringstream ss; | ||
char strbuf[256]; | ||
|
||
if (!getSelected()->isGameSystem()) | ||
ss << "CONFIGURATION"; | ||
else | ||
ss << gameCount << " GAMES AVAILABLE"; | ||
else { | ||
snprintf(strbuf, 256, ngettext("%i GAME AVAILABLE", "%i GAMES AVAILABLE", gameCount), gameCount); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use tabs vs 2 spaces |
||
ss << strbuf; | ||
} | ||
|
||
mSystemInfo.setText(ss.str()); | ||
}, false, 1); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "LocaleES.h" | ||
|
||
#ifndef HAVE_GETTEXT | ||
char* ngettext(char* msgid, char* msgid_plural, unsigned long int n) { | ||
if(n != 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use tabs vs 2 spaces |
||
return msgid_plural; | ||
} | ||
return msgid; | ||
} | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef _LOCALE_H_ | ||
#define _LOCALE_H_ | ||
|
||
#ifdef HAVE_GETTEXT | ||
#include <libintl.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use tabs vs 2 spaces |
||
#define _(A) gettext(A) | ||
#else | ||
#define _(A) A | ||
char* ngettext(char* msgid, char* msgid_plural, unsigned long int n); | ||
#endif | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
add_custom_target (i18n ALL COMMENT "Building i18n messages.") | ||
file (GLOB es_PO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/lang/*) | ||
set(es_POT ${CMAKE_CURRENT_SOURCE_DIR}/emulationstation.pot) | ||
# update the pot | ||
MESSAGE("Building the pot file") | ||
add_custom_command (TARGET i18n COMMAND find "${CMAKE_SOURCE_DIR}/es-app" "${CMAKE_SOURCE_DIR}/es-core" -name "*.cpp" -o -name "*.h" | ${XGETTEXT_EXECUTABLE} -f - -o ${es_POT} --no-location --keyword=_) | ||
|
||
foreach (es_PO_INPUT ${es_PO_FILES}) | ||
get_filename_component (es_PO_LANG ${es_PO_INPUT} NAME_WE) | ||
MESSAGE("LANG = ${es_PO_LANG}") | ||
set (es_MO_OUTPUT ${es_PO_INPUT}/LC_MESSAGES/emulationstation.mo) | ||
# update the po from the pot | ||
add_custom_command (TARGET i18n COMMAND basename ${es_PO_INPUT} && ${MSGMERGE_EXECUTABLE} -U --no-fuzzy-matching ${es_PO_INPUT}/LC_MESSAGES/emulationstation.po ${es_POT}) | ||
# compile the po to mo | ||
add_custom_command (TARGET i18n COMMAND ${MSGFMT_EXECUTABLE} -o ${es_MO_OUTPUT} ${es_PO_INPUT}/LC_MESSAGES/emulationstation.po --statistics) | ||
install (FILES ${es_MO_OUTPUT} DESTINATION share/locale/${es_PO_LANG}/LC_MESSAGES RENAME emulationstation.mo) | ||
endforeach (es_PO_INPUT ${es_PO_FILES}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
(cd lang && | ||
for POLANG in * | ||
do | ||
POFILE="./${POLANG}/LC_MESSAGES/emulationstation.po" | ||
echo -n "${POLANG}: " | ||
LANG=C msgfmt "${POFILE}" -o - --statistics > /dev/null | ||
done | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | ||
# This file is distributed under the same license as the PACKAGE package. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2019-07-19 10:06+0200\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"Language: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=CHARSET\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" | ||
|
||
#, c-format | ||
msgid "%i GAME AVAILABLE" | ||
msgid_plural "%i GAMES AVAILABLE" | ||
msgstr[0] "" | ||
msgstr[1] "" | ||
|
||
msgid "Loading..." | ||
msgstr "" | ||
|
||
msgid "Loading system config..." | ||
msgstr "" | ||
|
||
msgid "QUIT" | ||
msgstr "" | ||
|
||
msgid "Done." | ||
msgstr "" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: emulationstation\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2019-05-12 22:25+0200\n" | ||
"Language: fr\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"X-Generator: POEditor.com\n" | ||
"Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||
|
||
#, c-format | ||
msgid "%i GAME AVAILABLE" | ||
msgid_plural "%i GAMES AVAILABLE" | ||
msgstr[0] "%i JEU DISPONIBLE" | ||
msgstr[1] "%i JEUX DISPONIBLES" | ||
|
||
msgid "Loading..." | ||
msgstr "Chargement..." | ||
|
||
msgid "Loading system config..." | ||
msgstr "Chargement de la configuration système" | ||
|
||
msgid "QUIT" | ||
msgstr "QUITTER" | ||
|
||
msgid "Done." | ||
msgstr "Terminé." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add an option to disable even if all programs are available?