mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/i18n] Remove Language::Default
We never translate a i18n message to something else than the currrent language selected
This commit is contained in:
committed by
EmilieNumworks
parent
c58456a058
commit
19b5653851
@@ -1,5 +1,4 @@
|
|||||||
#include "empty_battery_window.h"
|
#include "empty_battery_window.h"
|
||||||
#include "global_preferences.h"
|
|
||||||
#include <apps/i18n.h>
|
#include <apps/i18n.h>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -12,7 +11,7 @@ EmptyBatteryWindow::EmptyBatteryWindow() :
|
|||||||
|
|
||||||
void EmptyBatteryWindow::drawRect(KDContext * ctx, KDRect rect) const {
|
void EmptyBatteryWindow::drawRect(KDContext * ctx, KDRect rect) const {
|
||||||
ctx->fillRect(bounds(), KDColorWhite);
|
ctx->fillRect(bounds(), KDColorWhite);
|
||||||
const char * warningMessage = I18n::translate(I18n::Message::LowBattery, GlobalPreferences::sharedGlobalPreferences()->language());
|
const char * warningMessage = I18n::translate(I18n::Message::LowBattery);
|
||||||
KDSize warningSize = KDFont::LargeFont->stringSize(warningMessage);
|
KDSize warningSize = KDFont::LargeFont->stringSize(warningMessage);
|
||||||
ctx->drawString(warningMessage, KDPoint((Ion::Display::Width - warningSize.width())/2, (Ion::Display::Height - warningSize.height())/2), KDFont::LargeFont);
|
ctx->drawString(warningMessage, KDPoint((Ion::Display::Width - warningSize.width())/2, (Ion::Display::Height - warningSize.height())/2), KDFont::LargeFont);
|
||||||
}
|
}
|
||||||
|
|||||||
13
apps/i18n.py
13
apps/i18n.py
@@ -95,7 +95,6 @@ def print_header(data, path, locales):
|
|||||||
|
|
||||||
# Languages enumeration
|
# Languages enumeration
|
||||||
f.write("enum class Language : uint16_t {\n")
|
f.write("enum class Language : uint16_t {\n")
|
||||||
f.write(" Default = 0,\n")
|
|
||||||
for locale in locales:
|
for locale in locales:
|
||||||
f.write(" " + locale.upper() + ",\n")
|
f.write(" " + locale.upper() + ",\n")
|
||||||
f.write("};\n\n")
|
f.write("};\n\n")
|
||||||
@@ -159,21 +158,17 @@ def print_implementation(data, path, locales):
|
|||||||
|
|
||||||
|
|
||||||
# Write the translate method
|
# Write the translate method
|
||||||
f.write("const char * translate(Message m, Language l) {\n")
|
f.write("const char * translate(Message m) {\n")
|
||||||
f.write(" assert(m != Message::LocalizedMessageMarker);\n")
|
f.write(" assert(m != Message::LocalizedMessageMarker);\n")
|
||||||
f.write(" int localizedMessageOffset = (int)Message::LocalizedMessageMarker+1;\n")
|
f.write(" int localizedMessageOffset = (int)Message::LocalizedMessageMarker+1;\n")
|
||||||
f.write(" if ((int)m < localizedMessageOffset) {\n")
|
f.write(" if ((int)m < localizedMessageOffset) {\n")
|
||||||
f.write(" assert(universalMessages[(int)m] != nullptr);\n")
|
f.write(" assert(universalMessages[(int)m] != nullptr);\n")
|
||||||
f.write(" return universalMessages[(int)m];\n")
|
f.write(" return universalMessages[(int)m];\n")
|
||||||
f.write(" }\n")
|
f.write(" }\n")
|
||||||
f.write(" int languageIndex = (int)l;\n")
|
f.write(" int languageIndex = (int)GlobalPreferences::sharedGlobalPreferences()->language();\n")
|
||||||
f.write(" if (l == Language::Default) {\n")
|
|
||||||
f.write(" languageIndex = (int) GlobalPreferences::sharedGlobalPreferences()->language();\n")
|
|
||||||
f.write(" }\n")
|
|
||||||
f.write(" assert(languageIndex > 0);\n")
|
|
||||||
f.write(" int messageIndex = (int)m - localizedMessageOffset;\n")
|
f.write(" int messageIndex = (int)m - localizedMessageOffset;\n")
|
||||||
f.write(" assert((messageIndex*NumberOfLanguages+languageIndex-1)*sizeof(char *) < sizeof(messages));\n")
|
f.write(" assert((messageIndex*NumberOfLanguages+languageIndex)*sizeof(char *) < sizeof(messages));\n")
|
||||||
f.write(" return messages[messageIndex][languageIndex-1];\n")
|
f.write(" return messages[messageIndex][languageIndex];\n")
|
||||||
f.write("}\n\n")
|
f.write("}\n\n")
|
||||||
f.write("}\n")
|
f.write("}\n")
|
||||||
f.close()
|
f.close()
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
|||||||
MessageTableCell * myCell = (MessageTableCell *)cell;
|
MessageTableCell * myCell = (MessageTableCell *)cell;
|
||||||
myCell->setMessage(title);
|
myCell->setMessage(title);
|
||||||
if (index == k_indexOfLanguageCell) {
|
if (index == k_indexOfLanguageCell) {
|
||||||
int index = (int)globalPreferences->language()-1;
|
int index = (int)(globalPreferences->language());
|
||||||
static_cast<MessageTableCellWithChevronAndMessage *>(cell)->setSubtitle(I18n::LanguageNames[index]);
|
static_cast<MessageTableCellWithChevronAndMessage *>(cell)->setSubtitle(I18n::LanguageNames[index]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ LanguageController::LanguageController(Responder * parentResponder, KDCoordinate
|
|||||||
|
|
||||||
void LanguageController::resetSelection() {
|
void LanguageController::resetSelection() {
|
||||||
m_selectableTableView.deselectTable();
|
m_selectableTableView.deselectTable();
|
||||||
int index = (int)GlobalPreferences::sharedGlobalPreferences()->language()-1;
|
selectCellAtLocation(0, (int)(GlobalPreferences::sharedGlobalPreferences()->language()));
|
||||||
selectCellAtLocation(0, index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * LanguageController::title() {
|
const char * LanguageController::title() {
|
||||||
@@ -41,7 +40,7 @@ void LanguageController::viewWillAppear() {
|
|||||||
|
|
||||||
bool LanguageController::handleEvent(Ion::Events::Event event) {
|
bool LanguageController::handleEvent(Ion::Events::Event event) {
|
||||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||||
GlobalPreferences::sharedGlobalPreferences()->setLanguage((I18n::Language)(selectedRow()+1));
|
GlobalPreferences::sharedGlobalPreferences()->setLanguage((I18n::Language)selectedRow());
|
||||||
/* We need to reload the whole title bar in order to translate both the
|
/* We need to reload the whole title bar in order to translate both the
|
||||||
* "Settings" title and the degree preference. */
|
* "Settings" title and the degree preference. */
|
||||||
AppsContainer::sharedAppsContainer()->reloadTitleBarView();
|
AppsContainer::sharedAppsContainer()->reloadTitleBarView();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
namespace I18n {
|
namespace I18n {
|
||||||
enum class Message : uint16_t;
|
enum class Message : uint16_t;
|
||||||
enum class Language : uint16_t;
|
enum class Language : uint16_t;
|
||||||
const char * translate(Message m, Language l = (Language)0);
|
const char * translate(Message m);
|
||||||
int numberOfLanguages();
|
int numberOfLanguages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace I18n {
|
namespace I18n {
|
||||||
|
|
||||||
const char * translate(Message m, Language l) {
|
const char * translate(Message m) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user