[ADD] Translation possibility for PorteAil homepage

master
Olivier DOSSMANN 2013-06-05 16:37:20 +02:00
parent c0205623b7
commit 84a95fb658
6 changed files with 21 additions and 4 deletions

View File

@ -25,7 +25,7 @@ ${MENU}
<!-- Footer -->
<footer>
<p>Proudly powered by <a href="http://porteail.e-mergence.org/" title="Go to PorteAil project official webpage">PorteAil</a></p>
<p>${POWERED_BY} <a href="http://porteail.e-mergence.org/" title="${POWERED_BY_DESC}">PorteAil</a></p>
</footer>
</body>
</html>

View File

@ -19,6 +19,7 @@ DESTINATION = porteail
##--[[ miscellaneous ]]--##
#LANG = en
#HOMEPAGE = Homepage - $(TITLE)
## File extension to be used to read categories
#CATEGORIES_EXT = txt

View File

@ -18,6 +18,7 @@ local default_dir_destination = 'porteail'
local default_dir_img_destination = 'image'
local default_dir_img_source = 'img'
local default_dir_css_source = 'style'
local default_dir_lang = 'lang'
-- Default files values
local default_img_filename = 'generique.png'
local default_index_filename = 'index.html'
@ -33,6 +34,7 @@ local DIR_SEP = '/'
local default_css_name = 'Default'
local default_title = 'My portal'
local default_homepage_title = ' - Homepage'
local default_language = 'en'
--[[ Functions ]]--
@ -262,7 +264,7 @@ else
end
-- Create index file in destination directory
result = assert(io.open(destination .. '/' .. main_template, 'wb'))
index_result = assert(io.open(destination .. '/' .. main_template, 'wb'))
-- create substitution table
substitutions = {
TITLE=config['HOMEPAGE'] or (config['TITLE'] and config['TITLE'] .. default_homepage_title) or (default_title .. default_homepage_title),
@ -274,11 +276,20 @@ substitutions = {
CSS_NAME=css_name,
DEFAULT_CSS=css_menu,
}
-- Get language configuration
language = config['LANG'] or default_language
languagerc = getConfig(default_dir_lang .. '/' .. language)
-- Add language translation to replacements table
for k, v in pairs(languagerc) do
substitutions[k] = v
end
-- replace variables in result
homepage = replace(index, substitutions)
assert(result:write(homepage))
assert(index_result:write(homepage))
-- close file
assert(result:close())
assert(index_result:close())
-- Copy miscellaneous files to destination
to_be_copied = {

2
lang/en 100644
View File

@ -0,0 +1,2 @@
POWERED_BY = Proudly powered by
POWERED_BY_DESC = Go to PorteAil project official webpage

2
lang/fr 100644
View File

@ -0,0 +1,2 @@
POWERED_BY = Fièrement propulsé par
POWERED_BY_DESC = Aller sur la page officielle du projet PorteAil

View File

@ -19,6 +19,7 @@ DESTINATION = porteail
##--[[ miscellaneous ]]--##
LANG = en
HOMEPAGE = Homepage - $(TITLE)
# File extension to be used to read categories
CATEGORIES_EXT = txt