diff --git a/composants/index.html b/composants/index.html index 414a0bb..1fa0b72 100644 --- a/composants/index.html +++ b/composants/index.html @@ -25,7 +25,7 @@ ${MENU} diff --git a/configrc.exemple b/configrc.exemple index 1be6b0c..a0dae4c 100644 --- a/configrc.exemple +++ b/configrc.exemple @@ -19,6 +19,7 @@ DESTINATION = porteail ##--[[ miscellaneous ]]--## +#LANG = en #HOMEPAGE = Homepage - $(TITLE) ## File extension to be used to read categories #CATEGORIES_EXT = txt diff --git a/create_homepage.lua b/create_homepage.lua index 77b0406..1591f32 100755 --- a/create_homepage.lua +++ b/create_homepage.lua @@ -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 = { diff --git a/lang/en b/lang/en new file mode 100644 index 0000000..741dc49 --- /dev/null +++ b/lang/en @@ -0,0 +1,2 @@ +POWERED_BY = Proudly powered by +POWERED_BY_DESC = Go to PorteAil project official webpage diff --git a/lang/fr b/lang/fr new file mode 100644 index 0000000..3f3aed3 --- /dev/null +++ b/lang/fr @@ -0,0 +1,2 @@ +POWERED_BY = Fièrement propulsé par +POWERED_BY_DESC = Aller sur la page officielle du projet PorteAil diff --git a/paconfigrc b/paconfigrc index 8bbef82..a6c89d1 100644 --- a/paconfigrc +++ b/paconfigrc @@ -19,6 +19,7 @@ DESTINATION = porteail ##--[[ miscellaneous ]]--## +LANG = en HOMEPAGE = Homepage - $(TITLE) # File extension to be used to read categories CATEGORIES_EXT = txt