diff options
-rw-r--r-- | apps/gui/bitmap/list.c | 31 | ||||
-rw-r--r-- | apps/gui/icon.c | 3 | ||||
-rw-r--r-- | apps/lang/arabic.lang | 3 | ||||
-rw-r--r-- | apps/lang/english.lang | 51 | ||||
-rw-r--r-- | apps/lang/hebrew.lang | 4 | ||||
-rw-r--r-- | apps/language.c | 13 | ||||
-rw-r--r-- | apps/language.h | 2 | ||||
-rw-r--r-- | apps/settings.h | 2 | ||||
-rw-r--r-- | apps/settings_list.c | 5 | ||||
-rw-r--r-- | firmware/drivers/lcd-bitmap-common.c | 8 | ||||
-rwxr-xr-x | tools/genlang | 24 |
11 files changed, 127 insertions, 19 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index 94870538d6..ff29397532 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include "sound.h" | 40 | #include "sound.h" |
41 | #include "misc.h" | 41 | #include "misc.h" |
42 | #include "viewport.h" | 42 | #include "viewport.h" |
43 | #include "language.h" | ||
43 | 44 | ||
44 | #define ICON_PADDING 1 | 45 | #define ICON_PADDING 1 |
45 | 46 | ||
@@ -61,6 +62,9 @@ bool list_display_title(struct gui_synclist *list, enum screen_type screen); | |||
61 | | | | items | I - icons | 62 | | | | items | I - icons |
62 | | | | | | 63 | | | | | |
63 | ------------------ | 64 | ------------------ |
65 | |||
66 | Note: This image is flipped horizontally when the language is a | ||
67 | right-to-left one (Hebrew, Arabic) | ||
64 | */ | 68 | */ |
65 | static bool draw_title(struct screen *display, struct gui_synclist *list) | 69 | static bool draw_title(struct screen *display, struct gui_synclist *list) |
66 | { | 70 | { |
@@ -77,10 +81,17 @@ static bool draw_title(struct screen *display, struct gui_synclist *list) | |||
77 | struct viewport title_icon = title_text[screen]; | 81 | struct viewport title_icon = title_text[screen]; |
78 | title_icon.width = get_icon_width(screen) | 82 | title_icon.width = get_icon_width(screen) |
79 | + ICON_PADDING*2; | 83 | + ICON_PADDING*2; |
80 | title_icon.x += ICON_PADDING; | 84 | if (lang_is_rtl()) |
81 | 85 | { | |
86 | title_icon.x = title_text[screen].width - ICON_PADDING - | ||
87 | get_icon_width(screen); | ||
88 | } | ||
89 | else | ||
90 | { | ||
91 | title_icon.x = ICON_PADDING; | ||
92 | title_text[screen].x += title_icon.width; | ||
93 | } | ||
82 | title_text[screen].width -= title_icon.width; | 94 | title_text[screen].width -= title_icon.width; |
83 | title_text[screen].x += title_icon.width; | ||
84 | 95 | ||
85 | display->set_viewport(&title_icon); | 96 | display->set_viewport(&title_icon); |
86 | screen_put_icon(display, 0, 0, list->title_icon); | 97 | screen_put_icon(display, 0, 0, list->title_icon); |
@@ -108,7 +119,7 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
108 | #ifdef HAVE_LCD_COLOR | 119 | #ifdef HAVE_LCD_COLOR |
109 | unsigned char cur_line = 0; | 120 | unsigned char cur_line = 0; |
110 | #endif | 121 | #endif |
111 | int item_offset; | 122 | int item_offset, is_rtl = lang_is_rtl(); |
112 | bool show_title; | 123 | bool show_title; |
113 | line_height = font_get(parent->font)->height; | 124 | line_height = font_get(parent->font)->height; |
114 | display->set_viewport(parent); | 125 | display->set_viewport(parent); |
@@ -132,12 +143,12 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
132 | vp = list_text[screen]; | 143 | vp = list_text[screen]; |
133 | vp.width = SCROLLBAR_WIDTH; | 144 | vp.width = SCROLLBAR_WIDTH; |
134 | list_text[screen].width -= SCROLLBAR_WIDTH; | 145 | list_text[screen].width -= SCROLLBAR_WIDTH; |
135 | if(global_settings.scrollbar == SCROLLBAR_LEFT) | 146 | if (global_settings.scrollbar == SCROLLBAR_SHOW) |
136 | list_text[screen].x += SCROLLBAR_WIDTH; | 147 | list_text[screen].x += SCROLLBAR_WIDTH; |
137 | vp.height = line_height * | 148 | vp.height = line_height * |
138 | viewport_get_nb_lines(&list_text[screen]); | 149 | viewport_get_nb_lines(&list_text[screen]); |
139 | vp.x = parent->x; | 150 | vp.x = parent->x; |
140 | if(global_settings.scrollbar == SCROLLBAR_RIGHT) | 151 | if (global_settings.scrollbar == SCROLLBAR_SHOW_OPPOSITE) |
141 | vp.x += list_text[screen].width; | 152 | vp.x += list_text[screen].width; |
142 | display->set_viewport(&vp); | 153 | display->set_viewport(&vp); |
143 | gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1, | 154 | gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1, |
@@ -149,7 +160,7 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
149 | else if (show_title) | 160 | else if (show_title) |
150 | { | 161 | { |
151 | /* shift everything right a bit... */ | 162 | /* shift everything right a bit... */ |
152 | if(global_settings.scrollbar == SCROLLBAR_LEFT) | 163 | if (global_settings.scrollbar == SCROLLBAR_SHOW) |
153 | { | 164 | { |
154 | list_text[screen].width -= SCROLLBAR_WIDTH; | 165 | list_text[screen].width -= SCROLLBAR_WIDTH; |
155 | list_text[screen].x += SCROLLBAR_WIDTH; | 166 | list_text[screen].x += SCROLLBAR_WIDTH; |
@@ -167,8 +178,10 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
167 | list_icons.width = icon_width * icon_count; | 178 | list_icons.width = icon_width * icon_count; |
168 | list_text[screen].width -= | 179 | list_text[screen].width -= |
169 | list_icons.width + ICON_PADDING; | 180 | list_icons.width + ICON_PADDING; |
170 | list_text[screen].x += | 181 | if (is_rtl) |
171 | list_icons.width + ICON_PADDING; | 182 | list_icons.x += list_text[screen].width; |
183 | else | ||
184 | list_text[screen].x += list_icons.width + ICON_PADDING; | ||
172 | } | 185 | } |
173 | 186 | ||
174 | for (i=start; i<end && i<list->nb_items; i++) | 187 | for (i=start; i<end && i<list->nb_items; i++) |
diff --git a/apps/gui/icon.c b/apps/gui/icon.c index 53cfd87774..a473c82872 100644 --- a/apps/gui/icon.c +++ b/apps/gui/icon.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "settings.h" | 29 | #include "settings.h" |
30 | #include "bmp.h" | 30 | #include "bmp.h" |
31 | #include "filetypes.h" | 31 | #include "filetypes.h" |
32 | #include "language.h" | ||
32 | 33 | ||
33 | #include "bitmaps/default_icons.h" | 34 | #include "bitmaps/default_icons.h" |
34 | #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) | 35 | #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) |
@@ -170,6 +171,8 @@ void screen_put_iconxy(struct screen * display, | |||
170 | #endif | 171 | #endif |
171 | draw_func = display->bitmap_part; | 172 | draw_func = display->bitmap_part; |
172 | 173 | ||
174 | if (lang_is_rtl()) | ||
175 | xpos = display->getwidth() - xpos - width; | ||
173 | draw_func(data, 0, height * icon, stride, xpos, ypos, width, height); | 176 | draw_func(data, 0, height * icon, stride, xpos, ypos, width, height); |
174 | } | 177 | } |
175 | 178 | ||
diff --git a/apps/lang/arabic.lang b/apps/lang/arabic.lang index c06af35560..73a98fe906 100644 --- a/apps/lang/arabic.lang +++ b/apps/lang/arabic.lang | |||
@@ -17,6 +17,9 @@ | |||
17 | # Arabic language file, translated by: | 17 | # Arabic language file, translated by: |
18 | # - Mohamed Tarek | 18 | # - Mohamed Tarek |
19 | # - Raafat Akkad | 19 | # - Raafat Akkad |
20 | <options> | ||
21 | rtl: 1 | ||
22 | </options> | ||
20 | <phrase> | 23 | <phrase> |
21 | id: LANG_EQUALIZER_HARDWARE_BANDWIDTH_NARROW | 24 | id: LANG_EQUALIZER_HARDWARE_BANDWIDTH_NARROW |
22 | desc: deprecated | 25 | desc: deprecated |
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 8be7380225..d34b2e9b32 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -13075,3 +13075,54 @@ | |||
13075 | swcodec: "Release Time" | 13075 | swcodec: "Release Time" |
13076 | </voice> | 13076 | </voice> |
13077 | </phrase> | 13077 | </phrase> |
13078 | <phrase> | ||
13079 | id: LANG_HIDE | ||
13080 | desc: in Settings -> General -> Display -> Status-/Scrollbar -> Scrollbar | ||
13081 | user: core | ||
13082 | <source> | ||
13083 | *: none | ||
13084 | lcd_bitmap: "Hide" | ||
13085 | </source> | ||
13086 | <dest> | ||
13087 | *: none | ||
13088 | lcd_bitmap: "Hide" | ||
13089 | </dest> | ||
13090 | <voice> | ||
13091 | *: none | ||
13092 | lcd_bitmap: "Hide" | ||
13093 | </voice> | ||
13094 | </phrase> | ||
13095 | <phrase> | ||
13096 | id: LANG_SHOW | ||
13097 | desc: in Settings -> General -> Display -> Status-/Scrollbar -> Scrollbar | ||
13098 | user: core | ||
13099 | <source> | ||
13100 | *: none | ||
13101 | lcd_bitmap: "Show" | ||
13102 | </source> | ||
13103 | <dest> | ||
13104 | *: none | ||
13105 | lcd_bitmap: "Show" | ||
13106 | </dest> | ||
13107 | <voice> | ||
13108 | *: none | ||
13109 | lcd_bitmap: "Show" | ||
13110 | </voice> | ||
13111 | </phrase> | ||
13112 | <phrase> | ||
13113 | id: LANG_SHOW_OPPOSITE | ||
13114 | desc: in Settings -> General -> Display -> Status-/Scrollbar -> Scrollbar | ||
13115 | user: core | ||
13116 | <source> | ||
13117 | *: none | ||
13118 | lcd_bitmap: "Show Opposite" | ||
13119 | </source> | ||
13120 | <dest> | ||
13121 | *: none | ||
13122 | lcd_bitmap: "Show Opposite" | ||
13123 | </dest> | ||
13124 | <voice> | ||
13125 | *: none | ||
13126 | lcd_bitmap: "Show Opposite" | ||
13127 | </voice> | ||
13128 | </phrase> | ||
diff --git a/apps/lang/hebrew.lang b/apps/lang/hebrew.lang index 76deb4d007..449bbfe0a0 100644 --- a/apps/lang/hebrew.lang +++ b/apps/lang/hebrew.lang | |||
@@ -20,6 +20,10 @@ | |||
20 | # - Rani Hod | 20 | # - Rani Hod |
21 | # - Tomer Shalev | 21 | # - Tomer Shalev |
22 | # - Sasha Khamkov | 22 | # - Sasha Khamkov |
23 | |||
24 | <options> | ||
25 | rtl: 1 | ||
26 | </options> | ||
23 | <phrase> | 27 | <phrase> |
24 | id: LANG_SET_BOOL_YES | 28 | id: LANG_SET_BOOL_YES |
25 | desc: bool true representation | 29 | desc: bool true representation |
diff --git a/apps/language.c b/apps/language.c index bba1359616..0c6245f08c 100644 --- a/apps/language.c +++ b/apps/language.c | |||
@@ -34,9 +34,10 @@ | |||
34 | /* These defines must match the initial bytes in the binary lang file */ | 34 | /* These defines must match the initial bytes in the binary lang file */ |
35 | /* See tools/genlang (TODO: Use common include for both) */ | 35 | /* See tools/genlang (TODO: Use common include for both) */ |
36 | #define LANGUAGE_COOKIE 0x1a | 36 | #define LANGUAGE_COOKIE 0x1a |
37 | #define LANGUAGE_VERSION 0x04 | 37 | #define LANGUAGE_VERSION 0x05 |
38 | #define LANGUAGE_FLAG_RTL 0x01 | ||
38 | 39 | ||
39 | #define HEADER_SIZE 3 | 40 | #define HEADER_SIZE 4 |
40 | 41 | ||
41 | static unsigned char language_buffer[MAX_LANGUAGE_SIZE]; | 42 | static unsigned char language_buffer[MAX_LANGUAGE_SIZE]; |
42 | 43 | ||
@@ -51,6 +52,13 @@ void lang_init(void) | |||
51 | } | 52 | } |
52 | } | 53 | } |
53 | 54 | ||
55 | static unsigned char lang_options = 0; | ||
56 | |||
57 | int lang_is_rtl(void) | ||
58 | { | ||
59 | return (lang_options & LANGUAGE_FLAG_RTL) != 0; | ||
60 | } | ||
61 | |||
54 | int lang_load(const char *filename) | 62 | int lang_load(const char *filename) |
55 | { | 63 | { |
56 | int fsize; | 64 | int fsize; |
@@ -98,6 +106,7 @@ int lang_load(const char *filename) | |||
98 | retcode = 3; | 106 | retcode = 3; |
99 | } | 107 | } |
100 | close(fd); | 108 | close(fd); |
109 | lang_options = (retcode ? 0 : lang_header[3]); | ||
101 | return retcode; | 110 | return retcode; |
102 | } | 111 | } |
103 | 112 | ||
diff --git a/apps/language.h b/apps/language.h index 06769a3dd9..c2a1b70e18 100644 --- a/apps/language.h +++ b/apps/language.h | |||
@@ -30,4 +30,6 @@ int lang_load(const char *filename); | |||
30 | /* get the ID of an english string so it can be localised */ | 30 | /* get the ID of an english string so it can be localised */ |
31 | int lang_english_to_id(const char* english); | 31 | int lang_english_to_id(const char* english); |
32 | 32 | ||
33 | /* returns whether the loaded language is a right-to-left language */ | ||
34 | int lang_is_rtl(void); | ||
33 | #endif | 35 | #endif |
diff --git a/apps/settings.h b/apps/settings.h index b208ee5872..b64fe37c74 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -158,7 +158,7 @@ enum { REPLAYGAIN_TRACK = 0, REPLAYGAIN_ALBUM, REPLAYGAIN_SHUFFLE, REPLAYGAIN_OF | |||
158 | enum { SHOW_PATH_OFF = 0, SHOW_PATH_CURRENT, SHOW_PATH_FULL }; | 158 | enum { SHOW_PATH_OFF = 0, SHOW_PATH_CURRENT, SHOW_PATH_FULL }; |
159 | 159 | ||
160 | /* scrollbar visibility/position */ | 160 | /* scrollbar visibility/position */ |
161 | enum { SCROLLBAR_OFF = 0, SCROLLBAR_LEFT, SCROLLBAR_RIGHT }; | 161 | enum { SCROLLBAR_HIDE = 0, SCROLLBAR_SHOW, SCROLLBAR_SHOW_OPPOSITE }; |
162 | 162 | ||
163 | /* Alarm settings */ | 163 | /* Alarm settings */ |
164 | #ifdef HAVE_RTC_ALARM | 164 | #ifdef HAVE_RTC_ALARM |
diff --git a/apps/settings_list.c b/apps/settings_list.c index 62a9351782..d76c2deb69 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c | |||
@@ -641,8 +641,9 @@ const struct settings_list settings[] = { | |||
641 | ID2P(LANG_STATUSBAR_BOTTOM)), | 641 | ID2P(LANG_STATUSBAR_BOTTOM)), |
642 | #endif | 642 | #endif |
643 | CHOICE_SETTING(F_THEMESETTING|F_TEMPVAR, scrollbar, | 643 | CHOICE_SETTING(F_THEMESETTING|F_TEMPVAR, scrollbar, |
644 | LANG_SCROLL_BAR, SCROLLBAR_LEFT, "scrollbar","off,left,right", | 644 | LANG_SCROLL_BAR, SCROLLBAR_SHOW, |
645 | NULL, 3, ID2P(LANG_OFF), ID2P(LANG_LEFT), ID2P(LANG_RIGHT)), | 645 | "scrollbar","hide,show,show_opposite", NULL, 3, |
646 | ID2P(LANG_HIDE), ID2P(LANG_SHOW), ID2P(LANG_SHOW_OPPOSITE)), | ||
646 | INT_SETTING(F_THEMESETTING, scrollbar_width, LANG_SCROLLBAR_WIDTH, 6, | 647 | INT_SETTING(F_THEMESETTING, scrollbar_width, LANG_SCROLLBAR_WIDTH, 6, |
647 | "scrollbar width",UNIT_INT, 3, MAX(LCD_WIDTH/10,25), 1, | 648 | "scrollbar width",UNIT_INT, 3, MAX(LCD_WIDTH/10,25), 1, |
648 | NULL, NULL, NULL), | 649 | NULL, NULL, NULL), |
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index c1efd9097e..8d3b88f8e1 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c | |||
@@ -27,6 +27,7 @@ | |||
27 | * KIND, either express or implied. | 27 | * KIND, either express or implied. |
28 | * | 28 | * |
29 | ****************************************************************************/ | 29 | ****************************************************************************/ |
30 | #include "language.h" | ||
30 | 31 | ||
31 | #ifndef LCDFN /* Not compiling for remote - define macros for main LCD. */ | 32 | #ifndef LCDFN /* Not compiling for remote - define macros for main LCD. */ |
32 | #define LCDFN(fn) lcd_ ## fn | 33 | #define LCDFN(fn) lcd_ ## fn |
@@ -170,11 +171,16 @@ void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str, | |||
170 | int style, int offset) | 171 | int style, int offset) |
171 | { | 172 | { |
172 | int xpos, ypos, w, h; | 173 | int xpos, ypos, w, h; |
174 | unsigned long chars_in_str; | ||
173 | LCDFN(scroll_stop_line)(current_vp, y); | 175 | LCDFN(scroll_stop_line)(current_vp, y); |
174 | if(!str || !str[0]) | 176 | if(!str || !str[0]) |
175 | return; | 177 | return; |
178 | |||
179 | chars_in_str = utf8length((char *)str); | ||
176 | LCDFN(getstringsize)(str, &w, &h); | 180 | LCDFN(getstringsize)(str, &w, &h); |
177 | xpos = x * w / utf8length((char *)str); | 181 | xpos = x * w / chars_in_str; |
182 | if (lang_is_rtl()) | ||
183 | xpos = current_vp->width - w - xpos; | ||
178 | ypos = y * h; | 184 | ypos = y * h; |
179 | LCDFN(putsxyofs_style)(xpos, ypos, str, style, w, h, offset); | 185 | LCDFN(putsxyofs_style)(xpos, ypos, str, style, w, h, offset); |
180 | } | 186 | } |
diff --git a/tools/genlang b/tools/genlang index d191a820a6..44dfcc6fdf 100755 --- a/tools/genlang +++ b/tools/genlang | |||
@@ -13,7 +13,8 @@ | |||
13 | # See apps/language.c (TODO: Use common include for both) | 13 | # See apps/language.c (TODO: Use common include for both) |
14 | # Cookie and binary version for the binary lang file | 14 | # Cookie and binary version for the binary lang file |
15 | my $LANGUAGE_COOKIE = 0x1a; | 15 | my $LANGUAGE_COOKIE = 0x1a; |
16 | my $LANGUAGE_VERSION = 0x04; | 16 | my $LANGUAGE_VERSION = 0x05; |
17 | my $LANGUAGE_FLAG_RTL = 0x01; | ||
17 | 18 | ||
18 | # A note for future users and readers: The original v1 language system allowed | 19 | # A note for future users and readers: The original v1 language system allowed |
19 | # the build to create and use a different language than english built-in. We | 20 | # the build to create and use a different language than english built-in. We |
@@ -167,6 +168,12 @@ sub phrase { | |||
167 | $phrase{$n}=$v; | 168 | $phrase{$n}=$v; |
168 | } | 169 | } |
169 | 170 | ||
171 | my %options; | ||
172 | sub options { | ||
173 | my ($full, $n, $v)=@_; | ||
174 | $options{$n}=$v; | ||
175 | } | ||
176 | |||
170 | sub parsetarget { | 177 | sub parsetarget { |
171 | my ($debug, $strref, $full, $n, $v)=@_; | 178 | my ($debug, $strref, $full, $n, $v)=@_; |
172 | my $string; | 179 | my $string; |
@@ -381,6 +388,8 @@ my $voiceid=0x8000; # counter for voice-only ID numbers | |||
381 | open(LANG, "<$input") || die "Error: couldn't read language file named $input\n"; | 388 | open(LANG, "<$input") || die "Error: couldn't read language file named $input\n"; |
382 | my @phrase; | 389 | my @phrase; |
383 | my $header = 1; | 390 | my $header = 1; |
391 | my $langoptions = 0; | ||
392 | |||
384 | while(<LANG>) { | 393 | while(<LANG>) { |
385 | 394 | ||
386 | $line++; | 395 | $line++; |
@@ -510,9 +519,15 @@ while(<LANG>) { | |||
510 | print "### $idstr: The phrase is not used. Skipped\n"; | 519 | print "### $idstr: The phrase is not used. Skipped\n"; |
511 | } | 520 | } |
512 | } | 521 | } |
513 | undef @phrase; | ||
514 | |||
515 | } # end of </phrase> | 522 | } # end of </phrase> |
523 | elsif($part eq "/options") { | ||
524 | # closing the options | ||
525 | if ($options{'rtl'}) { | ||
526 | $langoptions |= $LANGUAGE_FLAG_RTL; | ||
527 | } | ||
528 | } # end of </options> | ||
529 | |||
530 | undef @phrase; | ||
516 | 531 | ||
517 | # starts with a slash, this _ends_ this section | 532 | # starts with a slash, this _ends_ this section |
518 | $m = pop @m; # get back old value, the previous level's tag | 533 | $m = pop @m; # get back old value, the previous level's tag |
@@ -661,7 +676,8 @@ elsif($binary) { | |||
661 | 676 | ||
662 | open(OUTF, ">$binary") or die "Error: Can't create $binary"; | 677 | open(OUTF, ">$binary") or die "Error: Can't create $binary"; |
663 | binmode OUTF; | 678 | binmode OUTF; |
664 | printf OUTF ("%c%c%c", $LANGUAGE_COOKIE, $LANGUAGE_VERSION, $target_id); # magic lang file header | 679 | printf OUTF ("%c%c%c%c", $LANGUAGE_COOKIE, $LANGUAGE_VERSION, $target_id, |
680 | $langoptions); # magic lang file header | ||
665 | 681 | ||
666 | # loop over the target phrases | 682 | # loop over the target phrases |
667 | for $i (1 .. $idcount) { | 683 | for $i (1 .. $idcount) { |