webmcp
view framework/env/locale/_get_translation_table.lua @ 1:985024b16520
Version 1.0.1
New feature: JSON requests
Changes in ui.paginate: Current page setting is directly fetched from CGI params, instead of view params
Changed behavior of load methods of atom library to accept nil as input
Bugfixes in mondelefant_atom_connector timestamp(tz) loaders
Added global constant _WEBMCP_VERSION containing a version string
New feature: JSON requests
Changes in ui.paginate: Current page setting is directly fetched from CGI params, instead of view params
Changed behavior of load methods of atom library to accept nil as input
Bugfixes in mondelefant_atom_connector timestamp(tz) loaders
Added global constant _WEBMCP_VERSION containing a version string
| author | jbe | 
|---|---|
| date | Tue Nov 17 12:00:00 2009 +0100 (2009-11-17) | 
| parents | 9fdfb27f8e67 | 
| children | 3d43a5cf17c1 | 
 line source
     1 function locale._get_translation_table()
     2   local language_code = locale.get("lang")
     3   if language_code then
     4     if type(language_code) ~= "string" then
     5       error('locale.get("lang") does not return a string.')
     6     end
     7     local translation_table = locale._translation_tables[language_code]
     8     if translation_table then 
     9       return translation_table
    10     end
    11     local filename = encode.file_path(request.get_app_basepath(), "locale", "translations." .. language_code .. ".lua")
    12     local func = assert(loadfile(filename))
    13     setfenv(func, {})
    14     translation_table = func()
    15     if type(translation_table) ~= "table" then
    16       error("Translation file did not return a table.")
    17     end
    18     locale._translation_tables[language_code] = translation_table
    19     return translation_table
    20   else
    21     return locale._empty_translation_table
    22   end
    23 end
