Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: What function loads a .lang file?
From: TP Diffenbach (rockbox_at_diffenbach.org)
Date: 2003-04-27


Quoting Linus Nielsen Feltzing <linus_at_haxx.se>:

> [Your] current concept depends on the order of the strings. Use the
> str()
> macro and stay out of trouble.

And admittedly that's safer. But by using str() exclusively, I find that I repeat the same code in many functions to copy pointers from language_strings to a local array. It's tedious, and error-prone, and it bloats the code. I think we code save a non-trivial amount of code by insisting the lang strings be ordered.

My first thought was to do the copying, in one function, into static arrays, and call that function whenever a new lang file was loaded. My code would then refer to my static arrays. You objected to that as well, as it means keeping pointers to the internationalized strings. (Which is bad why? Will those strings be relocated at any tme other than when a lang file is loaded?)

Below is the code that gets repeated; note that even with what I'm doing, I can't remove the first ("chop_option") because "YES" comes before "NO" in language_strings:

    char* chop_option[] = {
        str( LANG_SET_BOOL_NO ),
        str( LANG_SET_BOOL_YES )
    } ;
    
    char* display_option[] = {
        str( LANG_FILE_PREFIX_OFFSET_AT ),
        str( LANG_FILE_PREFIX_OFFSET_AFTER )
    } ;
    
    char* character_class_option[] = {
        str( LANG_FILE_PREFIX_CHAR_CLASS_SPACE ),
        str( LANG_FILE_PREFIX_CHAR_CLASS_PUNC ),
        str( LANG_FILE_PREFIX_CHAR_CLASS_LETTER ),
        str( LANG_FILE_PREFIX_CHAR_CLASS_DIGIT ),
        str( LANG_FILE_PREFIX_CHAR_CLASS_LETTER_OR_DIGIT )
    } ;

-- 
Archos FM needs a Rockbox!



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa