I have extended welcome1stboot to run in all available languages now01micko wrote:YesL18L wrote:Do you plan to
- install all available translations of welcome1stboot so that they can be used immediately from the beginning
Should work without installing locale and without restarting X..
Name of language is from locales if existent (see example for French)
if LANGUAGE is set then there is no choice
For other translations we should wait until Barry has published his 3 versions variant I think.
EDIT
here is the source for this extension that has to be inserted.
Code: Select all
END SUB
REM ============================ <language> ======================140209
FUNCTION available_languages$()
LOCAL langs$
REM langs$=CONCAT$("en ", CHOP$(EXEC$("echo `find /usr/share/locale/*/LC_MESSAGES/welcome1stboot.mo | cut -d '/' -f 5`")))
langs$="en"
OPEN "/usr/share/locale/" FOR DIRECTORY AS textdomaindir
REPEAT
GETFILE oneLANG$ FROM textdomaindir
IF FILEEXISTS(CONCAT$("/usr/share/locale/", oneLANG$, "/LC_MESSAGES/", ARGUMENT$, ".mo")) THEN langs$=CONCAT$(langs$, " ", oneLANG$)
UNTIL ISFALSE(LEN(oneLANG$))
CLOSE DIRECTORY textdomaindir
RETURN langs$
END FUNCTION
'
' Print Unicode value to screen using UTF8 - See also http://www.unicode.org/charts/
'
' Install correct TTF font to make sure the UCS2 characters are printed correctly.
'
' For example the Junicode font: http://junicode.sourceforge.net/
'
' March 2011, PvE - GPL
'
'-----------------------------------------------------------------------
FUNCTION UCS2UTF8$(STRING number$)
LOCAL nr, byte1, byte2, byte3, utf1, utf2, utf3, utf4
LOCAL result$
nr = DEC(number$)
IF nr <= DEC("7f") THEN
byte1 = nr & 255
result$ = CHR$(byte1)
ELIF nr > DEC("7f") AND nr <= DEC("07ff") THEN
byte1 = nr & 255
byte2 = (nr & 65280) >> 8
utf1 = ((byte1 & 63) + 128)
utf2 = ((byte1 & 192) >> 6) + ((byte2 & 7) << 2) + 192
result$ = CONCAT$(CHR$(utf2), CHR$(utf1))
ELIF nr > DEC("07ff") AND nr <= DEC("ffff") THEN
byte1 = nr & 255
byte2 = (nr & 65280) >> 8
utf1 = ((nr & 63) + 128)
utf2 = ((byte1 & 192) >> 6) + ((byte2 & 15) << 2) + 128
utf3 = ((byte2 & 240) >> 4) + 224
result$ = CONCAT$(CHR$(utf3), CHR$(utf2), CHR$(utf1))
ELIF nr > DEC("ffff") AND nr <= DEC("10ffff") THEN
byte1 = nr & 255
byte2 = (nr & 65280) >> 8
byte3 = (nr & 16711680) >> 16
utf1 = ((nr & 63) + 128)
utf2 = ((byte1 & 192) >> 6) + ((byte2 & 15) << 2) + 128
utf3 = ((byte2 & 240) >> 4) + ((byte3 & 3) << 4) + 128
utf4 = ((byte3 & 28) >> 2) + 240
result$ = CONCAT$(CHR$(utf4), CHR$(utf3), CHR$(utf2), CHR$(utf1))
ELSE
PRINT "Value out of range."
END
END IF
RETURN result$
END FUNCTION
SUB get_app_language
OPTION BASE 1
GLOBAL num_languages
LOCAL num_cols = 4
GLOBAL language_checked[100]
REM GLOBAL language_select[100]
langs$=available_languages$ ()
SPLIT langs$ BY " " TO language$ SIZE num_languages
IF num_languages > 1 THEN
language_win = WINDOW(INTL$("Choose a language"), 285, 110 + 20 * num_languages / num_cols)
ATTACH(language_win, MARK(INTL$("Select one of the available languages\nyou like to use\nor are just curious about"),280,60), 2, 10)
REM checkboxes are used though only one choicen is making sense
REM but no need to press any additional key ie. no OK button required.
SHOW(language_win)
n = 1
row = 1
col = 1
WHILE n < num_languages + 1
' language_select[n] = RADIO(language$[n], 40, 15, 0)
' SET(language_select[n], 0)
' ATTACH(language_win, language_select[n], -20 + n * 50, 60)
' language_select[n] = BUTTON(language$[n], 40, 20)
' ATTACH(language_win, language_select[n], -20 + n * 50, 60)
language_checked[n] = CHECK(language$[n], 65, 15)
ATTACH(language_win, language_checked[n], 5 + (col -1) * 65 , 70 + row * 20 )
'get language name in language of language
IF n = 1 THEN LANG_NAME$="English"
ELSE
LANG_NAME$=""
lang_name$=EXEC$(CONCAT$("grep ^lang_name /usr/share/i18n/locales/", GRAB$(language_checked[n]), "* | head -n 1 | cut -d '"' -f2 ") )
lang_name$=REPLACE$(lang_name$,">","")
lang_name$=REPLACE$(lang_name$,"<U"," ")
FOR UCS$ IN lang_name$
LANG_NAME$=CONCAT$(LANG_NAME$, UCS2UTF8$(UCS$))
NEXT
IF LANG_NAME$="" THEN LANG_NAME$="This is the Language Code"
END IF
gtk_widget_set_tooltip_text(language_checked[n],LANG_NAME$)
CALLBACK(language_checked[n], check_language)
INCR n
INCR col
IF col > num_cols THEN
INCR row
col = 1
ENDIF
WEND
DISPLAY
ENDIF
END SUB
SUB check_language
lang$ = ""
REM checked can be more than one (in theory)
FOR n = 1 TO num_languages
IF GET(language_checked[n]) THEN lang$ = CONCAT$(lang$, GRAB$(language_checked[n]), " ")
NEXT
' restart this programm using a LANGUAGE
SYSTEM CONCAT$("LANGUAGE=", lang$, " ", ARGUMENT$)
SYSTEM CONCAT$("kill `pidof ", ARGUMENT$, "`")
END SUB
IF GETENVIRON$("LANGUAGE") = "" THEN get_app_language
REM ============================ </language> ======================140209
REM to disable decorations, need to hide window first...
Forget about above code.
Use recent version at http://www.murga-linux.com/puppy/viewto ... &start=558