webmcp

annotate framework/env/locale/_get_translation_table.lua @ 11:d76a8857ba62

Added ui.partial and other functions, which allow partial content replacement using XMLHttpRequests; Image support for ui.link

Also includes following changes:
- Fix for rocketcgi library to accept POST data content-types, which contain additional charset information.
- Support arrays passed as params to encode.url (only for keys ending with "[]")
- Version information changed to "1.0.7"

Documentation for added functions is not yet complete.
author jbe/bsw
date Fri Feb 12 18:40:22 2010 +0100 (2010-02-12)
parents 9fdfb27f8e67
children 3d43a5cf17c1
rev   line source
jbe/bsw@0 1 function locale._get_translation_table()
jbe/bsw@0 2 local language_code = locale.get("lang")
jbe/bsw@0 3 if language_code then
jbe/bsw@0 4 if type(language_code) ~= "string" then
jbe/bsw@0 5 error('locale.get("lang") does not return a string.')
jbe/bsw@0 6 end
jbe/bsw@0 7 local translation_table = locale._translation_tables[language_code]
jbe/bsw@0 8 if translation_table then
jbe/bsw@0 9 return translation_table
jbe/bsw@0 10 end
jbe/bsw@0 11 local filename = encode.file_path(request.get_app_basepath(), "locale", "translations." .. language_code .. ".lua")
jbe/bsw@0 12 local func = assert(loadfile(filename))
jbe/bsw@0 13 setfenv(func, {})
jbe/bsw@0 14 translation_table = func()
jbe/bsw@0 15 if type(translation_table) ~= "table" then
jbe/bsw@0 16 error("Translation file did not return a table.")
jbe/bsw@0 17 end
jbe/bsw@0 18 locale._translation_tables[language_code] = translation_table
jbe/bsw@0 19 return translation_table
jbe/bsw@0 20 else
jbe/bsw@0 21 return locale._empty_translation_table
jbe/bsw@0 22 end
jbe/bsw@0 23 end

Impressum / About Us