summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2009-09-26 00:58:32 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2009-09-26 00:58:32 +0000
commit340f32356ae39ba0b2e6fb1a2a7967f2d02e1777 (patch)
tree9165593d0c818ed8bcd637fd8c36cfe68f7f8446 /apps/gui
parentba8fbb0b9bb8db9f654b0120809e343516c02531 (diff)
downloadrockbox-340f32356ae39ba0b2e6fb1a2a7967f2d02e1777.tar.gz
rockbox-340f32356ae39ba0b2e6fb1a2a7967f2d02e1777.zip
new skin tag: %Sx|<english>| will display the current languages translation of the "<english>" string.
the <english> is the Source: bit in the .lang files. (must be exactly as it is there...) checkwps cannot verify that the string is correct so make sure to use the sim to verify the string is acurate. Also "fix" checkwps so %St|<setting>| can be accepted for the theme site git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22837 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/skin_engine/skin_parser.c59
-rw-r--r--apps/gui/skin_engine/skin_tokens.c3
-rw-r--r--apps/gui/skin_engine/skin_tokens.h1
-rw-r--r--apps/gui/skin_engine/wps_debug.c3
4 files changed, 48 insertions, 18 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index efe9f5228a..e62d473405 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -40,6 +40,7 @@
40#endif /*WPSEDITOR*/ 40#endif /*WPSEDITOR*/
41#else 41#else
42#include "debug.h" 42#include "debug.h"
43#include "language.h"
43#endif /*__PCTOOL__*/ 44#endif /*__PCTOOL__*/
44 45
45#include <ctype.h> 46#include <ctype.h>
@@ -132,7 +133,7 @@ static int parse_progressbar(const char *wps_bufptr,
132 struct wps_token *token, struct wps_data *wps_data); 133 struct wps_token *token, struct wps_data *wps_data);
133static int parse_dir_level(const char *wps_bufptr, 134static int parse_dir_level(const char *wps_bufptr,
134 struct wps_token *token, struct wps_data *wps_data); 135 struct wps_token *token, struct wps_data *wps_data);
135static int parse_setting(const char *wps_bufptr, 136static int parse_setting_and_lang(const char *wps_bufptr,
136 struct wps_token *token, struct wps_data *wps_data); 137 struct wps_token *token, struct wps_data *wps_data);
137 138
138#ifdef HAVE_LCD_BITMAP 139#ifdef HAVE_LCD_BITMAP
@@ -349,8 +350,11 @@ static const struct wps_tag all_tags[] = {
349#endif 350#endif
350#endif 351#endif
351 352
352 { WPS_TOKEN_SETTING, "St", WPS_REFRESH_DYNAMIC, parse_setting }, 353 { WPS_TOKEN_SETTING, "St", WPS_REFRESH_DYNAMIC,
353 354 parse_setting_and_lang },
355 { WPS_TOKEN_TRANSLATEDSTRING, "Sx", WPS_REFRESH_STATIC,
356 parse_setting_and_lang },
357
354 { WPS_TOKEN_LASTTOUCH, "Tl", WPS_REFRESH_DYNAMIC, parse_timeout }, 358 { WPS_TOKEN_LASTTOUCH, "Tl", WPS_REFRESH_DYNAMIC, parse_timeout },
355 { WPS_NO_TOKEN, "T", 0, parse_touchregion }, 359 { WPS_NO_TOKEN, "T", 0, parse_touchregion },
356 360
@@ -746,14 +750,20 @@ static int parse_image_special(const char *wps_bufptr,
746 750
747#endif /* HAVE_LCD_BITMAP */ 751#endif /* HAVE_LCD_BITMAP */
748 752
749static int parse_setting(const char *wps_bufptr, 753static int parse_setting_and_lang(const char *wps_bufptr,
750 struct wps_token *token, 754 struct wps_token *token,
751 struct wps_data *wps_data) 755 struct wps_data *wps_data)
752{ 756{
757 /* NOTE: both the string validations that happen in here will
758 * automatically PASS on checkwps because its too hard to get
759 * settings_list.c and englinsh.lang built for it.
760 * If that ever changes remove the #ifndef __PCTOOL__'s here
761 */
753 (void)wps_data; 762 (void)wps_data;
754 const char *ptr = wps_bufptr; 763 const char *ptr = wps_bufptr;
755 const char *end; 764 const char *end;
756 int i; 765 int i = 0;
766 char temp[64];
757 767
758 /* Find the setting's cfg_name */ 768 /* Find the setting's cfg_name */
759 if (*ptr != '|') 769 if (*ptr != '|')
@@ -762,17 +772,30 @@ static int parse_setting(const char *wps_bufptr,
762 end = strchr(ptr,'|'); 772 end = strchr(ptr,'|');
763 if (!end) 773 if (!end)
764 return WPS_ERROR_INVALID_PARAM; 774 return WPS_ERROR_INVALID_PARAM;
765 775 strlcpy(temp, ptr,end-ptr+1);
766 /* Find the setting */ 776
767 for (i=0; i<nb_settings; i++) 777 if (token->type == WPS_TOKEN_TRANSLATEDSTRING)
768 if (settings[i].cfg_name && 778 {
769 !strncmp(settings[i].cfg_name,ptr,end-ptr) && 779#ifndef __PCTOOL__
770 /* prevent matches on cfg_name prefixes */ 780 i = lang_english_to_id(temp);
771 strlen(settings[i].cfg_name)==(size_t)(end-ptr)) 781 if (i < 0)
772 break; 782 return WPS_ERROR_INVALID_PARAM;
773 if (i == nb_settings) 783#endif
774 return WPS_ERROR_INVALID_PARAM; 784 }
775 785 else
786 {
787 /* Find the setting */
788 for (i=0; i<nb_settings; i++)
789 if (settings[i].cfg_name &&
790 !strncmp(settings[i].cfg_name,ptr,end-ptr) &&
791 /* prevent matches on cfg_name prefixes */
792 strlen(settings[i].cfg_name)==(size_t)(end-ptr))
793 break;
794#ifndef __PCTOOL__
795 if (i == nb_settings)
796 return WPS_ERROR_INVALID_PARAM;
797#endif
798 }
776 /* Store the setting number */ 799 /* Store the setting number */
777 token->value.i = i; 800 token->value.i = i;
778 801
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index 94d8eb4dc6..758a8c1b04 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -170,6 +170,9 @@ const char *get_token_value(struct gui_wps *gwps,
170 170
171 case WPS_TOKEN_STRING: 171 case WPS_TOKEN_STRING:
172 return (char*)token->value.data; 172 return (char*)token->value.data;
173
174 case WPS_TOKEN_TRANSLATEDSTRING:
175 return (char*)P2STR(ID2P(token->value.i));
173 176
174 case WPS_TOKEN_TRACK_TIME_ELAPSED: 177 case WPS_TOKEN_TRACK_TIME_ELAPSED:
175 format_time(buf, buf_size, 178 format_time(buf, buf_size,
diff --git a/apps/gui/skin_engine/skin_tokens.h b/apps/gui/skin_engine/skin_tokens.h
index ad016047ba..86425424d9 100644
--- a/apps/gui/skin_engine/skin_tokens.h
+++ b/apps/gui/skin_engine/skin_tokens.h
@@ -32,6 +32,7 @@ enum wps_token_type {
32 /* Markers */ 32 /* Markers */
33 WPS_TOKEN_CHARACTER, 33 WPS_TOKEN_CHARACTER,
34 WPS_TOKEN_STRING, 34 WPS_TOKEN_STRING,
35 WPS_TOKEN_TRANSLATEDSTRING,
35 36
36 /* Alignment */ 37 /* Alignment */
37 WPS_TOKEN_ALIGN_LEFT, 38 WPS_TOKEN_ALIGN_LEFT,
diff --git a/apps/gui/skin_engine/wps_debug.c b/apps/gui/skin_engine/wps_debug.c
index df96548e9e..e06ce00219 100644
--- a/apps/gui/skin_engine/wps_debug.c
+++ b/apps/gui/skin_engine/wps_debug.c
@@ -76,6 +76,9 @@ static char *get_token_desc(struct wps_token *token, char *buf,
76 snprintf(buf, bufsize, "String '%s'", 76 snprintf(buf, bufsize, "String '%s'",
77 (char*)token->value.data); 77 (char*)token->value.data);
78 break; 78 break;
79 case WPS_TOKEN_TRANSLATEDSTRING:
80 snprintf(buf, bufsize, "String ID '%d'", token->value.i);
81 break;
79 82
80#ifdef HAVE_LCD_BITMAP 83#ifdef HAVE_LCD_BITMAP
81 case WPS_TOKEN_ALIGN_LEFT: 84 case WPS_TOKEN_ALIGN_LEFT: