am 5fa8c239: localization for recovery messages
* commit '5fa8c23911759a9e81af0e7fb5eb431277b8e9a6': localization for recovery messages
@@ -781,7 +781,7 @@ load_locale_from_cache() {
|
|||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
fgets(buffer, sizeof(buffer), fp);
|
fgets(buffer, sizeof(buffer), fp);
|
||||||
int j = 0;
|
int j = 0;
|
||||||
int i;
|
unsigned int i;
|
||||||
for (i = 0; i < sizeof(buffer) && buffer[i]; ++i) {
|
for (i = 0; i < sizeof(buffer) && buffer[i]; ++i) {
|
||||||
if (!isspace(buffer[i])) {
|
if (!isspace(buffer[i])) {
|
||||||
buffer[j++] = buffer[i];
|
buffer[j++] = buffer[i];
|
||||||
@@ -849,6 +849,7 @@ main(int argc, char **argv) {
|
|||||||
ui = device->GetUI();
|
ui = device->GetUI();
|
||||||
|
|
||||||
ui->Init();
|
ui->Init();
|
||||||
|
ui->SetLocale(locale);
|
||||||
ui->SetBackground(RecoveryUI::NONE);
|
ui->SetBackground(RecoveryUI::NONE);
|
||||||
if (show_text) ui->ShowText(true);
|
if (show_text) ui->ShowText(true);
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 844 B After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 40 KiB |
@@ -52,6 +52,7 @@ static double now() {
|
|||||||
ScreenRecoveryUI::ScreenRecoveryUI() :
|
ScreenRecoveryUI::ScreenRecoveryUI() :
|
||||||
currentIcon(NONE),
|
currentIcon(NONE),
|
||||||
installingFrame(0),
|
installingFrame(0),
|
||||||
|
rtl_locale(false),
|
||||||
progressBarType(EMPTY),
|
progressBarType(EMPTY),
|
||||||
progressScopeStart(0),
|
progressScopeStart(0),
|
||||||
progressScopeSize(0),
|
progressScopeSize(0),
|
||||||
@@ -158,18 +159,35 @@ void ScreenRecoveryUI::draw_progress_locked()
|
|||||||
float p = progressScopeStart + progress * progressScopeSize;
|
float p = progressScopeStart + progress * progressScopeSize;
|
||||||
int pos = (int) (p * width);
|
int pos = (int) (p * width);
|
||||||
|
|
||||||
if (pos > 0) {
|
if (rtl_locale) {
|
||||||
gr_blit(progressBarFill, 0, 0, pos, height, dx, dy);
|
// Fill the progress bar from right to left.
|
||||||
}
|
if (pos > 0) {
|
||||||
if (pos < width-1) {
|
gr_blit(progressBarFill, width-pos, 0, pos, height, dx+width-pos, dy);
|
||||||
gr_blit(progressBarEmpty, pos, 0, width-pos, height, dx+pos, dy);
|
}
|
||||||
|
if (pos < width-1) {
|
||||||
|
gr_blit(progressBarEmpty, 0, 0, width-pos, height, dx, dy);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Fill the progress bar from left to right.
|
||||||
|
if (pos > 0) {
|
||||||
|
gr_blit(progressBarFill, 0, 0, pos, height, dx, dy);
|
||||||
|
}
|
||||||
|
if (pos < width-1) {
|
||||||
|
gr_blit(progressBarEmpty, pos, 0, width-pos, height, dx+pos, dy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progressBarType == INDETERMINATE) {
|
if (progressBarType == INDETERMINATE) {
|
||||||
static int frame = 0;
|
static int frame = 0;
|
||||||
gr_blit(progressBarIndeterminate[frame], 0, 0, width, height, dx, dy);
|
gr_blit(progressBarIndeterminate[frame], 0, 0, width, height, dx, dy);
|
||||||
frame = (frame + 1) % indeterminate_frames;
|
// in RTL locales, we run the animation backwards, which
|
||||||
|
// makes the spinner spin the other way.
|
||||||
|
if (rtl_locale) {
|
||||||
|
frame = (frame + indeterminate_frames - 1) % indeterminate_frames;
|
||||||
|
} else {
|
||||||
|
frame = (frame + 1) % indeterminate_frames;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,6 +378,28 @@ void ScreenRecoveryUI::Init()
|
|||||||
RecoveryUI::Init();
|
RecoveryUI::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenRecoveryUI::SetLocale(const char* locale) {
|
||||||
|
if (locale) {
|
||||||
|
char* lang = strdup(locale);
|
||||||
|
for (char* p = lang; *p; ++p) {
|
||||||
|
if (*p == '_') {
|
||||||
|
*p = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A bit cheesy: keep an explicit list of supported languages
|
||||||
|
// that are RTL.
|
||||||
|
if (strcmp(lang, "ar") == 0 || // Arabic
|
||||||
|
strcmp(lang, "fa") == 0 || // Persian (Farsi)
|
||||||
|
strcmp(lang, "he") == 0 || // Hebrew (new language code)
|
||||||
|
strcmp(lang, "iw") == 0) { // Hebrew (old language code)
|
||||||
|
rtl_locale = true;
|
||||||
|
}
|
||||||
|
free(lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenRecoveryUI::SetBackground(Icon icon)
|
void ScreenRecoveryUI::SetBackground(Icon icon)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&updateMutex);
|
pthread_mutex_lock(&updateMutex);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class ScreenRecoveryUI : public RecoveryUI {
|
|||||||
ScreenRecoveryUI();
|
ScreenRecoveryUI();
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
void SetLocale(const char* locale);
|
||||||
|
|
||||||
// overall recovery state ("background image")
|
// overall recovery state ("background image")
|
||||||
void SetBackground(Icon icon);
|
void SetBackground(Icon icon);
|
||||||
@@ -55,6 +56,7 @@ class ScreenRecoveryUI : public RecoveryUI {
|
|||||||
private:
|
private:
|
||||||
Icon currentIcon;
|
Icon currentIcon;
|
||||||
int installingFrame;
|
int installingFrame;
|
||||||
|
bool rtl_locale;
|
||||||
|
|
||||||
pthread_mutex_t updateMutex;
|
pthread_mutex_t updateMutex;
|
||||||
gr_surface backgroundIcon[5];
|
gr_surface backgroundIcon[5];
|
||||||
|
|||||||
3
ui.h
@@ -30,6 +30,9 @@ class RecoveryUI {
|
|||||||
// Initialize the object; called before anything else.
|
// Initialize the object; called before anything else.
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
|
|
||||||
|
// After calling Init(), you can tell the UI what locale it is operating in.
|
||||||
|
virtual void SetLocale(const char* locale) { }
|
||||||
|
|
||||||
// Set the overall recovery state ("background image").
|
// Set the overall recovery state ("background image").
|
||||||
enum Icon { NONE, INSTALLING_UPDATE, ERASING, NO_COMMAND, ERROR };
|
enum Icon { NONE, INSTALLING_UPDATE, ERASING, NO_COMMAND, ERROR };
|
||||||
virtual void SetBackground(Icon icon) = 0;
|
virtual void SetBackground(Icon icon) = 0;
|
||||||
|
|||||||