multilingual scripts - LUA Scripting - CHDK Forum

multilingual scripts

  • 1 Replies
  • 2064 Views
*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
multilingual scripts
« on: 01 / December / 2013, 17:29:06 »
Advertisements
For some scripts it is necessary to display messages in the native language.

For that we can read the language setting in the camera via propertycase. Here is a little function for multilingual support in scripts.
Code: (lua) [Select]
-- get language
function get_language()
    --available language definitions in script are true
    local language = {}
    language[1]  = true  --en
    language[2]  = true  --de
    language[3]  = false --fr
    language[11] = false --es
    language[13] = false --ru
    --for more see: [url]http://chdk.wikia.com/wiki/PropertyCase[/url]
    local lng
    if get_propset() == 1 then
        lng = get_prop(196)/256             -- 1/2 en, 257/258 de, 513/514 fr, 2305/2306 es, 2817/2818 ru
        if lng >  7 then lng = lng + 1 end  -- ukrainian not in propset1
        if lng > 22 then lng = lng + 1 end  -- romanian not in propset1
    else
        lng = get_prop(61)/256              -- 0/1 en, 256/257 de, 512/513 fr, 2560/2561 es, 3072/3073 ru
    end
    lng = lng + 1
    --returns language id if true or English as default
    return language[lng] and lng or 1
end

lang_id = get_language()

str = {}
str[1] = "English"
str[2] = "Deutsch"

print(str[lang_id])
CHDK-DE:  CHDK-DE links

Re: multilingual scripts
« Reply #1 on: 01 / December / 2013, 18:38:55 »
I think a version of this would be worth adding to the CHDK/LUALIB directory in the standard distribution package.

Code: [Select]
lang = require("languages")
« Last Edit: 01 / December / 2013, 18:41:38 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics


SimplePortal © 2008-2014, SimplePortal