Skip to content
This repository
Browse code

[wiki] add the keyboard name to the wiki.inf file

This means that the nls_key2 message have all been removed
(which simplifies the translation generation

i.e. the commits create from translatewiki can be used directly
     without any manual fixes

Translation page is at:

  http://translatewiki.net/wiki/Translating:WikiReader

Signed-off-by: Christopher Hall <hsw@openmoko.com>
  • Loading branch information...
commit ce085cea93470511dc9536f3b4923867358a7221 1 parent 33a6a9e
Christopher Hall hxw authored
16 XML-Licenses/wiki.inf
@@ -21,15 +21,15 @@
21 21 # CHINESE-PINYIN
22 22 # CHINESE-BOPOMO
23 23 #
24   -# supported nls index (wiki.nls key suffix):
  24 +# supported menu text
25 25 # -------------------
26   -# (0) - default set (e.g., wiki_name)
27   -# 2 - second set (e.g., wiki_name2)
  26 +#
  27 +# utf-8 string
28 28 #
29 29 # rule: category+language vs. folder name should be 1-1 correpondence
30 30 # (for the language link to work properly)
31 31 #
32   -# category language folder name default keyboard nls index
  32 +# category language folder name default keyboard menu text
33 33 # ----------- -------- ----------- ----------------- ---------
34 34 , cy, cypedia,
35 35 , da, dapedia, DANISH
@@ -53,8 +53,8 @@
53 53 , fr, frpedia,
54 54 , hu, hupedia,
55 55 , it, itpedia,
56   - , ja, japedia, JAPANESE-HIRAGANA
57   - , ja, japedia, JAPANESE-ROMAN, 2
  56 + , ja, japedia, JAPANESE-HIRAGANA, (ひらがな入力)
  57 + , ja, japedia, JAPANESE-ROMAN, (ローマ字入力)
58 58 , ko, kopedia, KOREAN
59 59 , nl, nlpedia,
60 60 , no, nopedia,
@@ -65,5 +65,5 @@
65 65 , sv, svpedia,
66 66 , simple, e0pedia,
67 67 , tr, trpedia,
68   - , zhs, zhpedia, CHINESE-PINYIN
69   - , zht, zhpedia, CHINESE-BOPOMO, 2
  68 + , zhs, zhpedia, CHINESE-PINYIN, (拼音)
  69 + , zht, zhpedia, CHINESE-BOPOMO, (注音)
2  wiki/lcd_buf_draw.c
@@ -1213,6 +1213,8 @@ int render_wiki_selection_with_pcf()
1213 1213 articleLink[article_link_count++].article_id = rendered_wiki_selection_count;
1214 1214 }
1215 1215 draw_string(get_wiki_name(rendered_wiki_selection_count));
  1216 + draw_string((const unsigned char *)" ");
  1217 + draw_string(get_wiki_extra_name(rendered_wiki_selection_count));
1216 1218 rendered_wiki_selection_count++;
1217 1219 lcd_draw_buf.current_x = 0;
1218 1220 lcd_draw_buf.current_y += lcd_draw_buf.line_height;
90 wiki/wiki_info.c
@@ -31,37 +31,8 @@
31 31 #include "search_fnd.h"
32 32 #include "guilib.h"
33 33
34   -WIKI_LIST wiki_list_default[] =
35   -{
36   - { 1, 1, WIKI_CAT_ENCYCLOPAEDIA, "en", "enpedia", KEYBOARD_CHAR, 0},
37   -#if 0
38   - // these are loaded from "wiki.inf" in the root of the SD Card
39   - // the standard default file is: XML-Licenses/wiki.inf
40   - { 2, 2, WIKI_CAT_ENCYCLOPAEDIA, "es", "espedia", KEYBOARD_CHAR, 0},
41   - { 3, 3, WIKI_CAT_ENCYCLOPAEDIA, "fr", "frpedia", KEYBOARD_CHAR, 0},
42   - { 4, 4, WIKI_CAT_ENCYCLOPAEDIA, "de", "depedia", KEYBOARD_CHAR, 0},
43   - { 5, 5, WIKI_CAT_ENCYCLOPAEDIA, "nl", "nlpedia", KEYBOARD_CHAR, 0},
44   - { 6, 6, WIKI_CAT_ENCYCLOPAEDIA, "pt", "ptpedia", KEYBOARD_CHAR, 0},
45   - { 7, 7, WIKI_CAT_ENCYCLOPAEDIA, "fi", "fipedia", KEYBOARD_CHAR, 0},
46   - { 8, 8, WIKI_CAT_ENCYCLOPAEDIA, "ja", "japedia", KEYBOARD_PHONE_STYLE_JP, 0},
47   - { 9, 8, WIKI_CAT_ENCYCLOPAEDIA, "ja", "japedia", KEYBOARD_CHAR_JP, 2},
48   - {10, 9, WIKI_CAT_ENCYCLOPAEDIA, "da", "dapedia", KEYBOARD_CHAR_DA, 0},
49   - {11, 10, WIKI_CAT_ENCYCLOPAEDIA, "no", "nopedia", KEYBOARD_CHAR, 0},
50   - {12, 11, WIKI_CAT_ENCYCLOPAEDIA, "hu", "hupedia", KEYBOARD_CHAR, 0},
51   - {13, 12, WIKI_CAT_ENCYCLOPAEDIA, "ko", "kopedia", KEYBOARD_CHAR_KO, 0},
52   - {14, 13, WIKI_CAT_ENCYCLOPAEDIA, "el", "elpedia", KEYBOARD_CHAR, 0},
53   - {15, 14, WIKI_CAT_ENCYCLOPAEDIA, "ru", "rupedia", KEYBOARD_CHAR, 0},
54   - {16, 15, WIKI_CAT_ENCYCLOPAEDIA, "zhs", "zhpedia", KEYBOARD_CHAR, 0},
55   - {17, 15, WIKI_CAT_ENCYCLOPAEDIA, "zht", "zhpedia", KEYBOARD_PHONE_STYLE_TW, 2},
56   - {18, 16, WIKI_CAT_ENCYCLOPAEDIA, "cy", "cypedia", KEYBOARD_CHAR, 0},
57   - {19, 17, WIKI_CAT_ENCYCLOPAEDIA, "pl", "plpedia", KEYBOARD_CHAR, 0},
58   - {20, 18, WIKI_CAT_ENCYCLOPAEDIA, "simple", "e0pedia", KEYBOARD_CHAR, 0},
59   - {21, 19, WIKI_CAT_QUOTE, "en", "enquote", KEYBOARD_CHAR, 0},
60   - {22, 20, WIKI_CAT_BOOKS, "en", "enbooks", KEYBOARD_CHAR, 0},
61   - {23, 21, WIKI_CAT_DICTIONARY, "en", "endict", KEYBOARD_CHAR, 0},
62   - {24, 22, WIKI_CAT_GUTENBERG, "en", "enguten", KEYBOARD_CHAR, 0},
63   - {25, 23, WIKI_CAT_ENCYCLOPAEDIA, "it", "itpedia", KEYBOARD_CHAR, 0},
64   -#endif
  34 +WIKI_LIST wiki_list_default[] = {
  35 + {1, 1, WIKI_CAT_ENCYCLOPAEDIA, "en", "enpedia", KEYBOARD_CHAR, ""},
65 36 };
66 37
67 38 WIKI_LIST *wiki_list;
@@ -84,7 +55,7 @@ PACTIVE_WIKI aActiveWikis = NULL;
84 55 extern int bShowPositioner;
85 56 WIKI_LICENSE_DRAW *pWikiLicenseDraw;
86 57
87   -unsigned char *get_nls_key_value(const char *key, unsigned char *key_pairs, long key_pairs_len, int wiki_nls_idx);
  58 +const unsigned char *get_nls_key_value(const char *key, unsigned char *key_pairs, long key_pairs_len);
88 59 int get_wiki_idx_from_serial_id(int wiki_serial_id);
89 60
90 61 #define MAX_LINE_SIZE 256
@@ -219,7 +190,6 @@ void init_wiki_info(void)
219 190 {
220 191 unsigned int i, j;
221 192 int fd;
222   - unsigned char *p;
223 193 int nWikiSerialId;
224 194 char line[MAX_LINE_SIZE], buf[MAX_LINE_SIZE], word[MAX_LINE_SIZE];
225 195 ssize_t nLineChars;
@@ -302,7 +272,9 @@ void init_wiki_info(void)
302 272 state = 99;
303 273 break;
304 274 case 4:
305   - wiki_list[nWikiList].wiki_nls_idx = atoi(word);
  275 + // whole structure was cleared
  276 + // so copy n-1 bytes
  277 + strncpy((char *)wiki_list[nWikiList].wiki_menu_extra, word, sizeof(wiki_list[nWikiList].wiki_menu_extra) - 1);
306 278 state++;
307 279 break;
308 280 default:
@@ -368,17 +340,17 @@ void init_wiki_info(void)
368 340 file_read(fd, pWikiIni, lenWikiIni);
369 341 file_close(fd);
370 342 pWikiIni[lenWikiIni] = '\0';
371   - p = pWikiIni;
372   - while (*p)
  343 + unsigned char *p0 = pWikiIni;
  344 + while (*p0)
373 345 {
374   - if (*p == '\r' || *p == '\n')
375   - *p = '\0';
376   - p++;
  346 + if (*p0 == '\r' || *p0 == '\n')
  347 + *p0 = '\0';
  348 + p0++;
377 349 }
378   - p = get_nls_key_value("positioner", pWikiIni, lenWikiIni, 0);
  350 + const unsigned char *p = get_nls_key_value("positioner", pWikiIni, lenWikiIni);
379 351 if (*p)
380 352 bShowPositioner = atoi((const char *)p);
381   - p = get_nls_key_value("wiki_id", pWikiIni, lenWikiIni, 0);
  353 + p = get_nls_key_value("wiki_id", pWikiIni, lenWikiIni);
382 354 if (*p)
383 355 {
384 356 nWikiSerialId = atoi((const char *)p);
@@ -527,6 +499,7 @@ uint32_t wiki_lang_link_search(const unsigned char *lang_link_str)
527 499 nCurrentWiki = nTempCurrentWiki;
528 500 return article_idx;
529 501 }
  502 +
530 503 char *get_wiki_file_path(int nWikiIdx, char *file_name)
531 504 {
532 505 static char sFilePath[32];
@@ -586,25 +559,19 @@ int get_wiki_serial_id_from_idx(unsigned int wiki_idx)
586 559 return 0;
587 560 }
588 561
589   -unsigned char *get_nls_key_value(const char *key, unsigned char *key_pairs, long key_pairs_len, int wiki_nls_idx)
  562 +const unsigned char *get_nls_key_value(const char *key, unsigned char *key_pairs, long key_pairs_len)
590 563 {
591 564 int i, j;
592 565 int key_len;
593 566 int bFound = 0;
594   - char local_key[64];
595   -
596   - if (wiki_nls_idx)
597   - sprintf(local_key, "%s%d", key, wiki_nls_idx); // try the key name with wiki_name_idx first
598   - else
599   - ustrcpy(local_key, key);
600 567
601   - key_len = ustrlen(local_key);
  568 + key_len = ustrlen(key);
602 569 i = 0;
603 570 while (i < key_pairs_len - key_len - 1 && !bFound)
604 571 {
605 572 for (j = 0; j < key_len; j++)
606 573 {
607   - if (local_key[j] != key_pairs[i + j])
  574 + if (key[j] != key_pairs[i + j])
608 575 break;
609 576 }
610 577 i += j;
@@ -622,10 +589,8 @@ unsigned char *get_nls_key_value(const char *key, unsigned char *key_pairs, long
622 589 }
623 590 if (bFound)
624 591 return &key_pairs[i + 1];
625   - else if (wiki_nls_idx)
626   - return get_nls_key_value(key, key_pairs, key_pairs_len, 0); // try the key name without wiki_name_idx
627 592 else
628   - return (unsigned char *)""; // *** VERY BAD: removes const
  593 + return (const unsigned char *)"";
629 594 }
630 595
631 596 const unsigned char *get_nls_text(const char *key)
@@ -671,7 +636,7 @@ const unsigned char *get_nls_text(const char *key)
671 636 if (aActiveWikis[nCurrentWiki].WikiNlsLen == 0)
672 637 return (const unsigned char *)"";
673 638
674   - return get_nls_key_value(key, aActiveWikis[nCurrentWiki].WikiNls, aActiveWikis[nCurrentWiki].WikiNlsLen, wiki_list[aActiveWikis[nCurrentWiki].WikiInfoIdx].wiki_nls_idx);
  639 + return get_nls_key_value(key, aActiveWikis[nCurrentWiki].WikiNls, aActiveWikis[nCurrentWiki].WikiNlsLen);
675 640 }
676 641 }
677 642
@@ -716,12 +681,26 @@ const unsigned char *get_wiki_name(int idx)
716 681 return pName;
717 682 }
718 683
  684 +// I think this will only work if get_wiki_name has just been called
  685 +const unsigned char *get_wiki_extra_name(int idx)
  686 +{
  687 + return wiki_list[aActiveWikis[idx].WikiInfoIdx].wiki_menu_extra;
  688 +}
  689 +
719 690 void wiki_ini_insert_keypair(char *key, char *keyval)
720 691 {
721   - unsigned char *p = get_nls_key_value(key, pWikiIni, lenWikiIni, 0);
  692 + const unsigned char *p = get_nls_key_value(key, pWikiIni, lenWikiIni);
722 693
723 694 if (*p)
724 695 {
  696 + debug_print("not sure about this");
  697 + debug_printf("p = %s\n", p);
  698 + debug_printf("k = %s\n", keyval);
  699 +#if 0
  700 +//*****************************************************************************
  701 +//***************** What does this do? ****************************************
  702 +//***************** Why does it write to somethis that is read-only? **********
  703 +//*****************************************************************************
725 704 if (ustrlen(p) < ustrlen(keyval))
726 705 {
727 706 int diff = ustrlen(keyval) - ustrlen(p);
@@ -740,6 +719,7 @@ void wiki_ini_insert_keypair(char *key, char *keyval)
740 719 memset(p, 0, ustrlen(keyval) + 1);
741 720 memcpy(p, keyval, ustrlen(keyval));
742 721 }
  722 +#endif
743 723 }
744 724 else if (lenWikiIni + ustrlen(key) + ustrlen(keyval) + 2 < sizeWikiIni)
745 725 {
3  wiki/wiki_info.h
@@ -49,7 +49,7 @@ typedef struct _WIKI_LIST {
49 49 char wiki_lang[10];
50 50 char wiki_folder[10];
51 51 KEYBOARD_MODE wiki_default_keyboard;
52   - int wiki_nls_idx; // 0 for using wiki_name entry in wiki.nls, 2 for using wiki_name2, etc.
  52 + unsigned char wiki_menu_extra[32];
53 53 } WIKI_LIST;
54 54
55 55 typedef struct _WIKI_LICENSE_DRAW {
@@ -74,6 +74,7 @@ const unsigned char *get_nls_text(const char *key);
74 74 const unsigned char *get_lang_link_display_text(const unsigned char *lang_link_str);
75 75 char *get_wiki_file_path(int nWikiIdx, char *file_name);
76 76 const unsigned char *get_wiki_name(int idx);
  77 +const unsigned char *get_wiki_extra_name(int idx);
77 78 void wiki_selection(void);
78 79 void set_wiki(int idx);
79 80 int get_wiki_idx_from_id(int wiki_id);
2  wiki/wikilib.c
@@ -381,7 +381,7 @@ void handle_search_key(struct keyboard_key *key, unsigned long ev_time)
381 381 return;
382 382 } else if (keycode == WL_KEY_TEMPERATURE) {
383 383 delay_us(100000);
384   - temperature_mode ++;
  384 + ++temperature_mode;
385 385 temperature_mode %= 3;
386 386 set_temperature_mode();
387 387 guilib_fb_lock();

0 comments on commit ce085ce

Please sign in to comment.
Something went wrong with that request. Please try again.