[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rockbox-cvs
Subject:    jdgordon: r22837 - in trunk/apps: . gui/skin_engine
From:       mailer () svn ! rockbox ! org
Date:       2009-09-26 0:58:32
Message-ID: 200909260058.n8Q0wW7C024476 () giant ! haxx ! se
[Download RAW message or body]

Date: 2009-09-26 02:58:32 +0200 (Sat, 26 Sep 2009)
New Revision: 22837

Log Message:
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


Modified:
   trunk/apps/gui/skin_engine/skin_parser.c
   trunk/apps/gui/skin_engine/skin_tokens.c
   trunk/apps/gui/skin_engine/skin_tokens.h
   trunk/apps/gui/skin_engine/wps_debug.c
   trunk/apps/language.c
   trunk/apps/language.h

Modified: trunk/apps/gui/skin_engine/skin_parser.c
===================================================================
--- trunk/apps/gui/skin_engine/skin_parser.c	2009-09-25 18:36:28 UTC (rev 22836)
+++ trunk/apps/gui/skin_engine/skin_parser.c	2009-09-26 00:58:32 UTC (rev 22837)
@@ -40,6 +40,7 @@
 #endif /*WPSEDITOR*/
 #else
 #include "debug.h"
+#include "language.h"
 #endif /*__PCTOOL__*/
 
 #include <ctype.h>
@@ -132,7 +133,7 @@
         struct wps_token *token, struct wps_data *wps_data);
 static int parse_dir_level(const char *wps_bufptr,
         struct wps_token *token, struct wps_data *wps_data);
-static int parse_setting(const char *wps_bufptr,
+static int parse_setting_and_lang(const char *wps_bufptr,
         struct wps_token *token, struct wps_data *wps_data);
 
 #ifdef HAVE_LCD_BITMAP
@@ -349,8 +350,11 @@
 #endif
 #endif
 
-    { WPS_TOKEN_SETTING,                  "St",  WPS_REFRESH_DYNAMIC, parse_setting \
                },
-
+    { WPS_TOKEN_SETTING,                  "St",  WPS_REFRESH_DYNAMIC,
+                                                    parse_setting_and_lang },    
+    { WPS_TOKEN_TRANSLATEDSTRING,         "Sx",  WPS_REFRESH_STATIC,
+                                                    parse_setting_and_lang },
+                                                    
     { WPS_TOKEN_LASTTOUCH,                "Tl",  WPS_REFRESH_DYNAMIC, parse_timeout \
                },
     { WPS_NO_TOKEN,                       "T",   0,    parse_touchregion      },
 
@@ -746,14 +750,20 @@
 
 #endif /* HAVE_LCD_BITMAP */
 
-static int parse_setting(const char *wps_bufptr,
-                         struct wps_token *token,
-                         struct wps_data *wps_data)
+static int parse_setting_and_lang(const char *wps_bufptr,
+                                 struct wps_token *token,
+                                 struct wps_data *wps_data)
 {
+    /* NOTE: both the string validations that happen in here will
+     * automatically PASS on checkwps because its too hard to get
+     * settings_list.c and englinsh.lang built for it. 
+     * If that ever changes remove the #ifndef __PCTOOL__'s here 
+     */
     (void)wps_data;
     const char *ptr = wps_bufptr;
     const char *end;
-    int i;
+    int i = 0;
+    char temp[64];
 
     /* Find the setting's cfg_name */
     if (*ptr != '|')
@@ -762,17 +772,30 @@
     end = strchr(ptr,'|');
     if (!end)
         return WPS_ERROR_INVALID_PARAM;
-
-    /* Find the setting */
-    for (i=0; i<nb_settings; i++)
-        if (settings[i].cfg_name &&
-            !strncmp(settings[i].cfg_name,ptr,end-ptr) &&
-            /* prevent matches on cfg_name prefixes */
-            strlen(settings[i].cfg_name)==(size_t)(end-ptr))
-            break;
-    if (i == nb_settings)
-        return WPS_ERROR_INVALID_PARAM;
-
+    strlcpy(temp, ptr,end-ptr+1);
+    
+    if (token->type == WPS_TOKEN_TRANSLATEDSTRING)
+    {
+#ifndef __PCTOOL__
+        i = lang_english_to_id(temp);
+        if (i < 0)
+            return WPS_ERROR_INVALID_PARAM;
+#endif
+    }
+    else
+    {
+        /* Find the setting */
+        for (i=0; i<nb_settings; i++)
+            if (settings[i].cfg_name &&
+                !strncmp(settings[i].cfg_name,ptr,end-ptr) &&
+                /* prevent matches on cfg_name prefixes */
+                strlen(settings[i].cfg_name)==(size_t)(end-ptr))
+                break;
+#ifndef __PCTOOL__
+        if (i == nb_settings)
+            return WPS_ERROR_INVALID_PARAM;
+#endif
+    }
     /* Store the setting number */
     token->value.i = i;
 

Modified: trunk/apps/gui/skin_engine/skin_tokens.c
===================================================================
--- trunk/apps/gui/skin_engine/skin_tokens.c	2009-09-25 18:36:28 UTC (rev 22836)
+++ trunk/apps/gui/skin_engine/skin_tokens.c	2009-09-26 00:58:32 UTC (rev 22837)
@@ -170,6 +170,9 @@
 
         case WPS_TOKEN_STRING:
             return (char*)token->value.data;
+            
+        case WPS_TOKEN_TRANSLATEDSTRING:
+            return (char*)P2STR(ID2P(token->value.i));
 
         case WPS_TOKEN_TRACK_TIME_ELAPSED:
             format_time(buf, buf_size,

Modified: trunk/apps/gui/skin_engine/skin_tokens.h
===================================================================
--- trunk/apps/gui/skin_engine/skin_tokens.h	2009-09-25 18:36:28 UTC (rev 22836)
+++ trunk/apps/gui/skin_engine/skin_tokens.h	2009-09-26 00:58:32 UTC (rev 22837)
@@ -32,6 +32,7 @@
     /* Markers */
     WPS_TOKEN_CHARACTER,
     WPS_TOKEN_STRING,
+    WPS_TOKEN_TRANSLATEDSTRING,
 
     /* Alignment */
     WPS_TOKEN_ALIGN_LEFT,

Modified: trunk/apps/gui/skin_engine/wps_debug.c
===================================================================
--- trunk/apps/gui/skin_engine/wps_debug.c	2009-09-25 18:36:28 UTC (rev 22836)
+++ trunk/apps/gui/skin_engine/wps_debug.c	2009-09-26 00:58:32 UTC (rev 22837)
@@ -76,6 +76,9 @@
             snprintf(buf, bufsize, "String '%s'",
                      (char*)token->value.data);
             break;
+        case WPS_TOKEN_TRANSLATEDSTRING:
+            snprintf(buf, bufsize, "String ID '%d'", token->value.i);
+            break;
 
 #ifdef HAVE_LCD_BITMAP
         case WPS_TOKEN_ALIGN_LEFT:

Modified: trunk/apps/language.c
===================================================================
--- trunk/apps/language.c	2009-09-25 18:36:28 UTC (rev 22836)
+++ trunk/apps/language.c	2009-09-26 00:58:32 UTC (rev 22837)
@@ -98,3 +98,16 @@
     close(fd);
     return retcode;
 }
+
+int lang_english_to_id(const char* english)
+{
+    int i;
+    unsigned char *ptr = (unsigned char *) language_builtin;
+    
+    for (i = 0; i < LANG_LAST_INDEX_IN_ARRAY; i++) {
+        if (!strcmp(ptr, english))
+            return i;
+        ptr += strlen((char *)ptr) + 1; /* advance pointer to next string */
+    }
+    return -1;
+}

Modified: trunk/apps/language.h
===================================================================
--- trunk/apps/language.h	2009-09-25 18:36:28 UTC (rev 22836)
+++ trunk/apps/language.h	2009-09-26 00:58:32 UTC (rev 22837)
@@ -27,4 +27,7 @@
 /* load a given language file */
 int lang_load(const char *filename);
 
+/* get the ID of an english string so it can be localised */
+int lang_english_to_id(const char* english);
+
 #endif

_______________________________________________
rockbox-cvs mailing list
rockbox-cvs@cool.haxx.se
http://cool.haxx.se/cgi-bin/mailman/listinfo/rockbox-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic