From 0da0a26268cc9dc6251773dcb0abeb247b6e20d4 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 25 Oct 2010 20:41:38 -0400 Subject: texpdf_format, i18n, set tex document header language (polyglossia) * i18n, introduce header @make: :language: internationalization using codes from http://www.debian.org/international/l10n/po/ at this time for texpdf, (able to satify needs of polyglossia for the likes of Brazilian Portugues) and in future for po files, where iso:639 for this purpose appears to have use limitations http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes * i18n, add code list and associated language (as listed by polyglossia) * texpdf_format, use param (@make: :language: (default english)), to set tex document language header (previously used file naming convention) --- CHANGELOG_v2 | 8 ++- data/doc/sisu/v2/CHANGELOG | 8 ++- lib/sisu/v2/i18n.rb | 156 +++++++++++++++++++++++++++++++++++++++++++ lib/sisu/v2/texpdf_format.rb | 56 ++++------------ 4 files changed, 183 insertions(+), 45 deletions(-) diff --git a/CHANGELOG_v2 b/CHANGELOG_v2 index ba788ee5..e55187cd 100644 --- a/CHANGELOG_v2 +++ b/CHANGELOG_v2 @@ -21,9 +21,15 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_2.7.8.orig.tar.gz [debian freeze, fix] * i18n, introduce header @make: :language: internationalization using codes - from http://www.debian.org/international/l10n/po/ + from http://www.debian.org/international/l10n/po/ at this time for texpdf, + (able to satify needs of polyglossia for the likes of Brazilian Portugues) + and in future for po files, where iso:639 for this purpose appears to have + use limitations http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes * param, extract @make: :language: information if provided, default "english" + * i18n, add code list and associated language (as listed by polyglossia) + * texpdf_format, use param (@make: :language: (default english)), to set + tex document language header (previously used file naming convention) * sisu.vim recognize @make: :language: (also elsewhere shortened :lang_code: from :language_code:) diff --git a/data/doc/sisu/v2/CHANGELOG b/data/doc/sisu/v2/CHANGELOG index 2152d4ac..743786b4 100644 --- a/data/doc/sisu/v2/CHANGELOG +++ b/data/doc/sisu/v2/CHANGELOG @@ -21,9 +21,15 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_2.7.8.orig.tar.gz [debian freeze, fix] * i18n, introduce header @make: :language: internationalization using codes - from http://www.debian.org/international/l10n/po/ + from http://www.debian.org/international/l10n/po/ at this time for texpdf, + (able to satify needs of polyglossia for the likes of Brazilian Portugues) + and in future for po files, where iso:639 for this purpose appears to have + use limitations http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes * param, extract @make: :language: information if provided, default "english" + * i18n, add code list and associated language (as listed by polyglossia) + * texpdf_format, use param (@make: :language: (default english)), to set + tex document language header (previously used file naming convention) * sisu.vim recognize @make: :language: (also elsewhere shortened :lang_code: from :language_code:) diff --git a/lib/sisu/v2/i18n.rb b/lib/sisu/v2/i18n.rb index 2aa730be..c43daabe 100644 --- a/lib/sisu/v2/i18n.rb +++ b/lib/sisu/v2/i18n.rb @@ -56,6 +56,90 @@ ** Description: internationalisation =end +module SiSU_i18n + class Language + def initialize(md) + @md=md + end + def tex_name(char) + @lang=if char + case char + when 'sq'; 'albanian' + when 'am'; 'amharic' + #when 'ar'; 'arabic' # see polyglossia + when 'hy'; 'armenian' + #when ''; 'asturian' # polyglossia + #when ''; 'bahasai' # polyglossia + #when ''; 'bahasam' # polyglossia + when 'eu'; 'basque' + when 'bn'; 'bengali' + when 'pt_BR'; 'brazilian' + when 'br'; 'breton' + when 'bg'; 'bulgarian' + when 'ca'; 'catalan' # see polyglossia + #when ''; 'coptic' # polyglossia + when 'hr'; 'croatian' + when 'cs'; 'czech' + when 'da'; 'danish' + #when ''; 'divehi' # polyglossia + when 'nl'; 'dutch' # see polyglossia + when 'en'; 'english' # see polyglossia + when 'eo'; 'esperanto' # see polyglossia + when 'et'; 'estonian' + when 'gl'; 'galician' + when 'de'; 'german' + when 'el'; 'greek' #gl ? + when 'he'; 'hebrew' + when 'hi'; 'hindi' + when 'is'; 'icelandic' + when 'ia'; 'interlingua' + when 'ga'; 'irish' + when 'it'; 'italian' + #when ''; 'farsi' # polyglossia + when 'fi'; 'finnish' + when 'fr'; 'french' + when 'lo'; 'lao' + when 'la'; 'latin' + when 'lv'; 'latvian' + when 'lt'; 'lithuanian' + #when ''; 'lsorbian' # polyglossia + #when ''; 'magyar' # polyglossia + when 'ml'; 'malayalam' + when 'mr'; 'marathi' + #when 'hu'; 'magyar' + when 'no'; 'norske' + when 'nn'; 'nynorsk' + when 'oc'; 'occitan' + when 'pl'; 'polish' + when 'pt'; 'portuges' + when 'ro'; 'romanian' + when 'ru'; 'russian' + when 'se'; 'samin' #(check sami?) + when 'sa'; 'sanskrit' + when 'sr'; 'serbian' + #when ''; 'scottish' # polyglossia (gd (Gaelic (Scots))) + when 'sk'; 'slovak' + when 'sl'; 'slovenian' + when 'es'; 'spanish' + when 'sv'; 'swedish' + when 'ta'; 'tamil' + when 'te'; 'telugu' + when 'th'; 'thai' + when 'tr'; 'turkish' + when 'tk'; 'turkmen' + when 'uk'; 'ukrainian' + when 'ur'; 'urdu' + #when ''; 'usorbian' # polyglossia + when 'vi'; 'vietnamese' + when 'cy'; 'welsh' + when 'us'; 'USenglish' # depreciated, see iso-639-2 + else 'english' + end + else 'english' + end + end + end +end module SiSU_Translate require "#{SiSU_lib}/sysenv" # sysenv.rb include SiSU_Env; include SiSU_Param @@ -93,6 +177,7 @@ module SiSU_Translate else English.new(md,doc_lang,trans_str) end end + def filename @lang_class.filename end @@ -1623,3 +1708,74 @@ module SiSU_Translate end end __END__ +http://www.debian.org/international/l10n/po/ +http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes +http://www.loc.gov/standards/iso639-2/php/code_list.php +albanian sq +amharic am +arabic ar +armenian hy +asturian +bahasai +bahasam +basque eu +bengali bn +brazil[ian] pt_BR +breton br +bulgarian bg +catalan ca +coptic +croatian hr +czech cs +danish da +divehi +dutch nl +english en +esperanto eo +estonian et +galician gl +german de +greek el +hebrew he +hindi hi +icelandic is +interlingua ia +irish ga +italian it +farsi +finnish fi +french fr +lao lo +latin la +latvian lv +lithuanian lt +lsorbian +magyar +malayalam ml +marathi mr +norsk no +nynorsk nn +occitan oc +polish pl +portuges pt +romanian ro +russian ru +samin se (check sami?) +sanskrit sa +scottish # (gd (Gaelic (Scots))) +serbian sr +slovak sk +slovenian sl +spanish es +swedish sv +syriac # (ar_SY (Arabic, as spoken in Syrian Arab Republic)) +tamil ta +telugu te +thai th +turkish tr +turkmen tk +ukrainian uk +urdu ur +usorbian +vietnamese vi +welsh cy diff --git a/lib/sisu/v2/texpdf_format.rb b/lib/sisu/v2/texpdf_format.rb index 9ebef9dc..465d4d90 100644 --- a/lib/sisu/v2/texpdf_format.rb +++ b/lib/sisu/v2/texpdf_format.rb @@ -604,6 +604,7 @@ module SiSU_TeX_Pdf end end class Format_head + require "#{SiSU_lib}/i18n" # defaults.rb def initialize(md,t_o) @md,@t_o=md,t_o @env=SiSU_Env::Info_env.new(@md.fns) @@ -621,47 +622,16 @@ module SiSU_TeX_Pdf @brace_url=SiSU_Viz::Skin.new.url_decoration @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine @ps=@txt if @txt=~/(?:a4|letter|legal|book|a5|b5)/i - end - def language - @lang=if @md.language[:code] - case @md.language[:code] - when 'en'; 'english' - when 'us'; 'USenglish' # depreciated, see iso-639-2 - when 'fr'; 'french' - when 'de'; 'ngerman' - when 'it'; 'italian' - when 'es'; 'spanish' - when 'pt'; 'portuges' - #when 'br'; 'brazilian' # depreciated, see iso-639-2 - when 'sv'; 'swedish' - when 'da'; 'danish' - when 'fi'; 'finnish' - when 'no'; 'norske,nynorsk' - when 'is'; 'icelandic' - when 'nl'; 'dutch' - when 'et'; 'estonian' - when 'hu'; 'magyar' - when 'pl'; 'polish' - when 'ro'; 'romanian' - when 'ru'; 'russian' - when 'gl'; 'greek' - when 'uk'; 'ukrainian' - when 'tr'; 'turkish' - when 'sk'; 'slovak' - when 'sl'; 'slovenian' - when 'hr'; 'croatian' - when 'cs'; 'czech' - when 'bg'; 'bulgarian' - else 'english' - end - else 'english' - end + @lang ||=SiSU_i18n::Language.new(@md) end def tex_head_lang #babel 18n - language - lang=if @lang =~/^(?:en)$/; @lang - else "#{@lang},english" - end + lang_char_arr=@md.i18n + mainlang_char=lang_char_arr.slice(0) + mainlang=@lang.tex_name(mainlang_char) + otherlang=[] + lang_char_arr.slice(1..9).each { |ch| otherlang << @lang.tex_name(ch) } + otherlang=otherlang.join(',') + { :mainlang=>mainlang, :otherlang=>otherlang } end def tex_head_encode texpdf_font=if defined? @md.make.texpdf_font \ @@ -674,8 +644,8 @@ module SiSU_TeX_Pdf when /xe/ <