diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/translations/translations.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/translations/translations.sty | 394 |
1 files changed, 266 insertions, 128 deletions
diff --git a/Master/texmf-dist/tex/latex/translations/translations.sty b/Master/texmf-dist/tex/latex/translations/translations.sty index d4f7c68b474..da3eca0e9aa 100644 --- a/Master/texmf-dist/tex/latex/translations/translations.sty +++ b/Master/texmf-dist/tex/latex/translations/translations.sty @@ -8,7 +8,7 @@ % Web: https://github.com/cgnieder/translations % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2012 Clemens Niederberger +% Copyright 2012-2014 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -25,67 +25,47 @@ % If you have any ideas, questions, suggestions or bugs to report, please % feel free to contact me. % -------------------------------------------------------------------------- -\def\@trnslt@date{2013/09/30} -\def\@trnslt@version{v1.1a} +\def\@trnslt@date{2014/01/10} +\def\@trnslt@version{v1.2} \def\@trnslt@info{internationalization of LaTeX2e packages} -\ProvidesPackage{translations}[\@trnslt@date\space \@trnslt@version\space \@trnslt@info\space (CN)] -\RequirePackage{etoolbox,scrlfile} +\ProvidesPackage{translations}[% + \@trnslt@date\space + \@trnslt@version\space + \@trnslt@info\space (CN)] +\RequirePackage{cnltx-base,scrlfile} % -------------------------------------------------------------------------- % message handling +% generic help message: \def\@trnslt@error@message{% - For details have a look at the `translations' manual.} - -\def\@trnslt@create@message#1{% - \ifstrequal{#1}{Error} - {% - \lowercase{\csdef{@trnslt@#1}}##1{% - \csuse{Package#1}{translations}{##1}{\@trnslt@error@message}}% - }{% - \lowercase{\csdef{@trnslt@#1}}##1{% - \csuse{Package#1}{translations}{##1}}% - }} -\@trnslt@create@message{Error} -\@trnslt@create@message{Warning} -\@trnslt@create@message{WarningNoLine} -\@trnslt@create@message{Info} - -\def\@trnslt@err@unknown@lang#1{% - \@trnslt@error{Unknown language `#1'}} - -\def\@trnslt@warn@unknown@lang#1{% - \@trnslt@warning{Unknown language `#1'}} - -\def\@trnslt@err@already@defined#1#2{% - \@trnslt@error{The #2 translation for `#1' is already defined.}} - -\def\@trnslt@err@not@defined#1#2{% - \@trnslt@error{The \@trnslt@language{#2} translation for `#1' is not defined yet.}} - -% -------------------------------------------------------------------------- -% catcode stuff: -\DeclareListParser*{\@trnslt@map@tokenlist}{} - -\def\@trnslt@save@catcodes#1{% - \@trnslt@map@tokenlist\@trnslt@save@catcode{#1}% -} -\def\@trnslt@save@catcode#1{% - \csedef{@trnslt@catcode@#1}{\the\catcode`#1}% + For details have a look at the `translations' manual.% } -\def\@trnslt@restore@catcodes#1{% - \@trnslt@map@tokenlist\@trnslt@restore@catcode{#1}% +% create message macros: +\cnltx@create@generic@message{@trnslt}{translations}{Error}{\@trnslt@error@message} +\cnltx@create@generic@message{@trnslt}{translations}{Warning}{} +\cnltx@create@generic@message{@trnslt}{translations}{WarningNoLine}{} +\cnltx@create@generic@message{@trnslt}{translations}{Info}{} + +% specific errors: +\newrobustcmd*\@trnslt@err@unknown@lang[1]{\@trnslt@error{Unknown language `#1'}} +\newrobustcmd*\@trnslt@warn@unknown@lang[1]{\@trnslt@warning{Unknown language `#1'}} +\newrobustcmd*\@trnslt@err@already@defined[2]{% + \@trnslt@error{The #2 translation for `#1' is already defined.}% } -\protected\def\@trnslt@restore@catcode#1{% - \catcode`#1=\csname @trnslt@catcode@#1\endcsname +\newrobustcmd*\@trnslt@err@not@defined[2]{% + \@trnslt@error{% + The \@trnslt@language{#2} translation for `#1' is not defined yet.% + }% } - -\def\@trnslt@set@catcodes#1#2{% - \@trnslt@map@tokenlist{\@trnslt@set@catcode{#2}}{#1}% +\newrobustcmd*\@trnslt@err@dict@already@defined[2]{% + \@trnslt@error{The #2 dictionary entry for `#1' is already defined.}% } -\def\@trnslt@set@catcode#1#2{% - \catcode`#2=#1\relax +\newrobustcmd*\@trnslt@err@dict@not@defined[2]{% + \@trnslt@error{% + The \@trnslt@language{#2} dictionary entry for `#1' is not defined yet.% + }% } % -------------------------------------------------------------------------- @@ -93,12 +73,13 @@ \AtEndPreamble{ \@ifpackageloaded{babel}{}{ \@ifpackageloaded{polyglossia}{} - {\@trnslt@warning{No language package found. I am going to use `english' + {\@trnslt@info{No language package found. I am going to use `english' as default language.}} } - \ifdef\languagename{} - {\def\languagename{english}} - \def\@trnslt@current@language{\languagename} + % define \languagename if not defined yet: + \providecommand*\languagename{english}% + \def\@trnslt@current@language{\languagename}% + % define \bbl@afterfi if not defined yet: \ifdef\bbl@afterfi{} {\long\def\bbl@afterfi#1\fi{\fi#1}} } @@ -106,18 +87,18 @@ % -------------------------------------------------------------------------- % book keeping: the following macros will be used as `etoolbox' lists that % keep record of defined languages, dialects and aliases -\def\@trnslt@languages{}% all languages -\def\@trnslt@aliases@pair{}% all aliases and their base -\def\@trnslt@aliases@single{}% all aliases -\def\@trnslt@dialects@pair{}% all dialects and their base -\def\@trnslt@dialects@single{}% all dialects +\newcommand*\@trnslt@languages{}% all languages +\newcommand*\@trnslt@aliases@pair{}% all aliases and their base +\newcommand*\@trnslt@aliases@single{}% all aliases +\newcommand*\@trnslt@dialects@pair{}% all dialects and their base +\newcommand*\@trnslt@dialects@single{}% all dialects % -------------------------------------------------------------------------- % define \@trnslt@if@<name> conditionals that don't leave the checked macro as % \relax behind and check for \@trnslt@<name>@#1. These conditionals should % also be expandable in an \edef-like context. Thanks to e-TeX there's % \ifcsname: -\def\@trnslt@new@check#1{% +\newrobustcmd*\@trnslt@new@check[1]{% \csdef{@trnslt@if@#1}##1{% \ifcsname @trnslt@#1@##1\endcsname \expandafter\@firstoftwo @@ -128,7 +109,9 @@ } % -------------------------------------------------------------------------- -\long\def\@trnslt@get@lowercase#1{% +% leaves lowercase full expansion of #1 in the input stream (except that it +% doesn't, because nothing is expanded... :p) +\newcommand\@trnslt@get@lowercase[1]{% \lowercase\expandafter{\romannumeral-`\Q#1}% } @@ -139,7 +122,7 @@ \@trnslt@declare@language{#1}} \@onlypreamble\DeclareLanguage -\def\@trnslt@declare@language#1{% +\newrobustcmd*\@trnslt@declare@language[1]{% \@trnslt@if@language{#1} {}{% \csdef{@trnslt@language@#1}{#1}% @@ -147,9 +130,11 @@ }% } -\def\@trnslt@language#1{% - \csuse{@trnslt@language@#1}} +% get the name declared by \DeclareLanguage: the underlying name of a given +% language; this is not the base of a dialect! +\newcommand*\@trnslt@language[1]{\csuse{@trnslt@language@#1}} +% a user-level equivalent: \newcommand*\baselanguage[1]{\@trnslt@language{#1}} % define \@trnslt@if@language{#1}{}{} that actually checks the existence of @@ -164,7 +149,7 @@ \@trnslt@declare@languagedialect{#1}{#2}} \@onlypreamble\DeclareLanguageDialect -\def\@trnslt@declare@languagedialect#1#2{% +\newrobustcmd*\@trnslt@declare@languagedialect[2]{% \@trnslt@if@language{#2} {}{% \@trnslt@warn@unknown@lang{#2}% @@ -176,7 +161,7 @@ {% \@trnslt@if@alias{#2} {% - \csedef{@trnslt@dialect@#1}{{\@trnslt@alias{#2}}{#1}}% + \csedef{@trnslt@dialect@#1@trnslt@dialect@#1}{{\@trnslt@alias{#2}}{#1}}% \@trnslt@declare@language{#1}% \listeadd\@trnslt@dialects@single{#1}% \listeadd\@trnslt@dialects@pair{{#1}{\@trnslt@alias{#2}}}% @@ -190,11 +175,11 @@ }% } -\def\@trnslt@dialect#1{% - \csuse{@trnslt@dialect@#1}} +% dialect equivalent of \@trnslt@language +\newcommand*\@trnslt@dialect[1]{\csuse{@trnslt@dialect@#1}} % this macros fetches the base language for a given dialect, expandably: -\def\@trnslt@dialect@of#1{% +\newcommand*\@trnslt@dialect@of[1]{% \@trnslt@if@dialect{#1} {% \expandafter\expandafter\expandafter @@ -203,6 +188,14 @@ }{}% } +% get the underlying name of a language or the name of the base language of a +% dialect: +\newcommand*\baselanguagename[1]{% + \@trnslt@if@dialect{#1} + {\baselanguage{\@trnslt@dialect@of{#1}}} + {\baselanguage{#1}}% +} + % define \@trnslt@if@dialect{#1}{}{} that actually checks the existence of % \@trnslt@dialect@#1: \@trnslt@new@check{dialect} @@ -215,7 +208,7 @@ \@trnslt@declare@languagealias{#1}{#2}} \@onlypreamble\DeclareLanguageAlias -\def\@trnslt@declare@languagealias#1#2{% +\newrobustcmd*\@trnslt@declare@languagealias[2]{% \@trnslt@if@language{#2} {}{% \@trnslt@warn@unknown@lang{#2}% @@ -233,43 +226,86 @@ }% } -\def\@trnslt@alias#1{% - \csuse{@trnslt@alias@#1}} +% alias equivalent of \@trnslt@language +\newcommand*\@trnslt@alias[1]{\csuse{@trnslt@alias@#1}} % define \@trnslt@if@alias{#1}{}{} that actually checks the existence of % \@trnslt@alias@#1: \@trnslt@new@check{alias} % -------------------------------------------------------------------------- -% dummy language: `fallback': -\DeclareLanguage{fallback} -\DeclareLanguageAlias{Fallback}{fallback} +% check the current language, expandably: +% #1: language +% #2: true +% #3: false +\newcommand*\@trnslt@iflanguage[1]{% + \cnltx@braced@expanded@fully + \cnltx@braced@expanded@fully + \cnltx@firstofone + \cnltx@ifstrequal + {\baselanguage{#1}} + {\baselanguage{\languagename}}% +} + +% check the current /base/ language, expandably: +\newcommand*\@trnslt@ifbaselanguage[1]{% + \@trnslt@if@dialect{\languagename} + {% + \cnltx@braced@expanded@fully + \cnltx@braced@expanded@fully + \cnltx@firstofone + \cnltx@ifstrequal + {\baselanguage{\@trnslt@dialect@of{\languagename}}} + {\baselanguage{#1}}% + } + {\@trnslt@iflanguage{#1}}% +} + +% user commands for the above: +\newcommand*\ifcurrentlanguage[1]{% + \@trnslt@iflanguage{#1}% +} +\newcommand*\ifcurrentbaselanguage[1]{% + \@trnslt@ifbaselanguage{#1}% +} % -------------------------------------------------------------------------- -% \DeclareTranslation, \NewTranslation and \RenewTranslation +% Now that we can define languages we also want to be able to define +% translations: +% \DeclareTranslation, \NewTranslation, \RenewTranslation and +% \ProvideTranslation % #1: language % #2: word % #3: replacement \newrobustcmd*\DeclareTranslation[3]{% - \@trnslt@declare@translation{#2}{#1}{#3}} + \@trnslt@declare@translation{#2}{#1}{#3}% +} \@onlypreamble\DeclareTranslation \newrobustcmd*\DeclareTranslationFallback[2]{% - \@trnslt@declare@translation{#1}{fallback}{#2}} + \@trnslt@declare@translation{#1}{fallback}{#2}% +} \@onlypreamble\DeclareTranslationFallback \newrobustcmd*\NewTranslation[3]{% - \@trnslt@new@translation{#2}{#1}{#3}} + \@trnslt@new@translation{#2}{#1}{#3}% +} \@onlypreamble\NewTranslation \newrobustcmd*\RenewTranslation[3]{% - \@trnslt@renew@translation{#2}{#1}{#3}} + \@trnslt@renew@translation{#2}{#1}{#3}% +} \@onlypreamble\RenewTranslation +\newrobustcmd*\ProvideTranslation[3]{% + \@trnslt@provide@translation{#2}{#1}{#3}% +} +\@onlypreamble\ProvideTranslation + % #1: word % #2: language % #3: replacement -\def\@trnslt@declare@translation#1#2#3{% +\newrobustcmd*\@trnslt@declare@translation[3]{% \@trnslt@if@language{#2} {% \@trnslt@if@dialect{#2} @@ -286,19 +322,27 @@ {\@trnslt@err@unknown@lang{#2}}% } -\def\@trnslt@new@translation#1#2#3{% +\newrobustcmd*\@trnslt@new@translation[3]{% \@trnslt@if@word\@trnslt@language{#1}{#2} {\@trnslt@err@already@defined{#1}{#2}} - {\@trnslt@declare@translation{#1}{#2}{#3}}} + {\@trnslt@declare@translation{#1}{#2}{#3}}% +} -\def\@trnslt@renew@translation#1#2#3{% +\newrobustcmd*\@trnslt@renew@translation[3]{% \@trnslt@if@word\@trnslt@language{#1}{#2} {\@trnslt@declare@translation{#1}{#2}{#3}} - {\@trnslt@err@not@defined{#1}{#2}}} + {\@trnslt@err@not@defined{#1}{#2}}% +} + +\newrobustcmd*\@trnslt@provide@translation[3]{% + \@trnslt@if@word\@trnslt@language{#1}{#2} + {} + {\@trnslt@declare@translation{#1}{#2}{#3}}% +} % -------------------------------------------------------------------------- -% now let's go through some trouble to check if a translation exists: -\def\@trnslt@if@word#1#2#3{% +% let's go through some trouble to check if a translation exists: +\newcommand*\@trnslt@if@word[3]{% \ifcsname @trnslt@word@#2@#1{#3}\endcsname \expandafter\@firstoftwo \else @@ -306,7 +350,7 @@ \fi }% -\def\@trnslt@if@translation#1#2{% +\newcommand*\@trnslt@if@translation[2]{% \@trnslt@if@word\@trnslt@language{#1}{#2} {\expandafter\@firstoftwo} {% @@ -325,6 +369,7 @@ } % -------------------------------------------------------------------------- +% We also need to be able to look up a translation: % \GetTranslationFor and \GetTranslation % these need to be expandable! % #1: language @@ -335,6 +380,13 @@ \newcommand*\GetTranslation[1]{% \@trnslt@checkandget@translation@for{#1}{\@trnslt@current@language}} +% those will print the translation lowercase... they're also expandable; that +% is: nearly... +% \DeclareTranslation{German}{foo}{Bla} +% \edef\foo{\GetLCTranslationFor{German}{foo}} +% \show\foo +% > \foo=macro: +% ->\lowercase {Bla}. \newcommand*\GetLCTranslationFor[2]{% \@trnslt@get@lowercase{\@trnslt@checkandget@translation@for{#2}{#1}}% } @@ -347,20 +399,24 @@ % unexpandable version of the commands that raise a warning if no translation % is available: -\newcommand*\GetTranslationForWarn[2]{% - \@trnslt@getandwarn@translation@for{#2}{#1}} +\newrobustcmd*\GetTranslationForWarn[2]{% + \@trnslt@getandwarn@translation@for{#2}{#1}% +} -\newcommand*\GetTranslationWarn[1]{% - \@trnslt@getandwarn@translation@for{#1}{\@trnslt@current@language}} +\newrobustcmd*\GetTranslationWarn[1]{% + \@trnslt@getandwarn@translation@for{#1}{\@trnslt@current@language}% +} -\newcommand*\GetLCTranslationForWarn[2]{% - \@trnslt@getandwarn@lctranslation@for{#2}{#1}} +\newrobustcmd*\GetLCTranslationForWarn[2]{% + \@trnslt@getandwarn@lctranslation@for{#2}{#1}% +} -\newcommand*\GetLCTranslationWarn[1]{% - \@trnslt@getandwarn@lctranslation@for{#1}{\@trnslt@current@language}} +\newrobustcmd*\GetLCTranslationWarn[1]{% + \@trnslt@getandwarn@lctranslation@for{#1}{\@trnslt@current@language}% +} % #1: word #2: language -\def\@trnslt@get@translation@for#1#2{% +\newcommand*\@trnslt@get@translation@for[2]{% \@trnslt@if@dialect{#2} {% \ifcsdef{@trnslt@word@#1@\@trnslt@dialect{#2}} @@ -370,7 +426,7 @@ {\csuse{@trnslt@word@#1@\@trnslt@language{#2}}}% } -\def\@trnslt@checkandget@translation@for#1#2{% +\newcommand*\@trnslt@checkandget@translation@for[2]{% \@trnslt@if@translation{#1}{#2} {\@trnslt@get@translation@for{#1}{#2}} {% @@ -381,7 +437,7 @@ } % this is not expandable! -\protected\def\@trnslt@getandwarn@translation@for#1#2{% +\newrobustcmd*\@trnslt@getandwarn@translation@for[2]{% \@trnslt@if@translation{#1}{#2} {\@trnslt@get@translation@for{#1}{#2}} {% @@ -397,7 +453,7 @@ } % lowercase version for translation with warnings: -\protected\def\@trnslt@getandwarn@lctranslation@for#1#2{% +\newrobustcmd*\@trnslt@getandwarn@lctranslation@for[2]{% \@trnslt@if@translation{#1}{#2} {\@trnslt@get@lowercase{\@trnslt@get@translation@for{#1}{#2}}} {% @@ -413,21 +469,30 @@ } % -------------------------------------------------------------------------- +% no idea if the following ones really are needed... let's define them +% anyway % \SaveTranslationFor and \SaveTranslation \newrobustcmd*\SaveTranslationFor[3]{% - \@trnslt@save@translation@for{#1}{#3}{#2}} + \@trnslt@save@translation@for{#1}{#3}{#2}% +} \newrobustcmd*\SaveTranslation[2]{% - \@trnslt@save@translation@for{#1}{#2}{\@trnslt@current@language}} + \@trnslt@save@translation@for{#1}{#2}{\@trnslt@current@language}% +} -\def\@trnslt@save@translation@for#1#2#3{% +\newrobustcmd*\@trnslt@save@translation@for[3]{% \edef#1{% \@trnslt@if@translation{#2}{#3} {\csuse{@trnslt@word@#2@\@trnslt@language{#3}}} {}% - }} + }% +} % -------------------------------------------------------------------------- +% The basics are set. What's missing? Right: dictionaries! Those will be files +% that contain translations for a specific language. +% -------------------------------------------------------------------------- +% load dictionaries and check for existing ones: % \LoadDictionary and \LoadDictionaryFor \newrobustcmd*\LoadDictionary[1]{% \@trnslt@load@dictionary@for{#1}{\@trnslt@current@language}} @@ -439,15 +504,18 @@ % #1: name % #2: lang -\def\@trnslt@load@dictionary@for#1#2{% +\newrobustcmd*\@trnslt@load@dictionary@for[2]{% \AtBeginDocument{% \InputIfFileExists{#1-\@trnslt@language{#2}.trsl} {\@trnslt@check@dictionary{#1}{#2}} - {\@trnslt@warning{dictionary file `#1-\@trnslt@language{#2}.trsl' not - found.}}% - }} + {% + \@trnslt@warning{dictionary file `#1-\@trnslt@language{#2}.trsl' not + found.}% + }% + }% +} -\def\@trnslt@check@dictionary#1#2{% +\newrobustcmd*\@trnslt@check@dictionary[2]{% \AfterFile{#1-\@trnslt@language{#2}.trsl} {% \ifcsdef{@trnslt@dictionary@#1@\@trnslt@language{#2}} @@ -459,17 +527,17 @@ }% } -\def\@trnslt@if@dictionary#1#2{% - \IfFileExists{#1-#2.trsl}} +\newcommand*\@trnslt@if@dictionary[2]{\IfFileExists{#1-#2.trsl}} -\def\@trnslt@load@dictionary@silent@for#1#2{% - \InputIfFileExists{#1-#2.trsl}{}{}} +\newcommand*\@trnslt@load@dictionary@silent@for[2]{\InputIfFileExists{#1-#2.trsl}{}{}} +% -------------------------------------------------------------------------- +% the contents of a dictionary; let's declare that is one. \newrobustcmd*\ProvideDictionaryFor[2]{% \@trnslt@provide@dictionary@for{#1}{#2}} \@onlypreamble\ProvideDictionaryFor -\def\@trnslt@provide@dictionary@for#1#2{% +\newrobustcmd*\@trnslt@provide@dictionary@for[2]{% \def\@trnslt@dictionary@name{#2}% \edef\@trnslt@dictionary@lang{\@trnslt@language{#1}}% % this macro can be used to check if we have a dictionary and will also be @@ -484,20 +552,64 @@ }% } -\def\@trnslt@provide@dictionary@version[#1]{% +\protected\def\@trnslt@provide@dictionary@version[#1]{% \ProvidesFile {\@trnslt@dictionary@name-\@trnslt@dictionary@lang.trsl}% [(\@trnslt@dictionary@lang\space translation file `\@trnslt@dictionary@name') #1]} -% \@trnslt@dictionary@language -\newrobustcmd*\DeclareDictTranslation[2]{% +% change this test (we can't use braces inside the item with \ifinlist): +\newcommand*\@trnslt@check@dictionary@entry[2]{% + \cnltx@ifinlistcs + {{#1}{#2}} + {@trnslt@dictionary@\@trnslt@dictionary@name @\@trnslt@dictionary@lang}% +} + +\newrobustcmd*\@trnslt@add@dictionary@entry[2]{% \listcsadd {@trnslt@dictionary@\@trnslt@dictionary@name @\@trnslt@dictionary@lang} {{#1}{#2}}% +} + +% -------------------------------------------------------------------------- +% now we should be able to add translations without repeatedly type the +% language ... +\newrobustcmd*\NewDictTranslation[2]{% + \@trnslt@check@dictionary@entry{#1}{#2} + {\@trnslt@err@dict@already@defined{#1}{#2}}% + {% + \@trnslt@add@dictionary@entry{#1}{#2} + \@trnslt@new@translation{#1}{\@trnslt@dictionary@lang}{#2}% + }% +} +\@onlypreamble\NewDictTranslation + +\newrobustcmd*\RenewDictTranslation[2]{% + \@trnslt@check@dictionary@entry{#1}{#2} + {\@trnslt@renew@translation{#1}{\@trnslt@dictionary@lang}{#2}} + {\@trnslt@err@dict@not@defined{#1}{#2}}% +} +\@onlypreamble\RenewDictTranslation + +\newrobustcmd*\DeclareDictTranslation[2]{% + \@trnslt@check@dictionary@entry{#1}{#2} + {} + {\@trnslt@add@dictionary@entry{#1}{#2}}% \@trnslt@declare@translation{#1}{\@trnslt@dictionary@lang}{#2}% } \@onlypreamble\DeclareDictTranslation +\newrobustcmd*\ProvideDictTranslation[2]{% + \@trnslt@check@dictionary@entry{#1}{#2} + {} + {% + \@trnslt@add@dictionary@entry{#1}{#2}% + \@trnslt@provide@translation{#1}{\@trnslt@dictionary@lang}{#2}% + }% +} +\@onlypreamble\ProvideDictTranslation + +% -------------------------------------------------------------------------- +% last not least let's inspect which entries a dictionary contains of: % \PrintDictionaryFor % #1: lang % #2: name @@ -505,14 +617,15 @@ % #4: mid % #5: post \newcommand*\PrintDictionaryFor[5]{% - \@trnslt@print@dictionary@for{#1}{#2}{#3}{#4}{#5}} + \@trnslt@print@dictionary@for{#1}{#2}{#3}{#4}{#5}% +} % #1: lang % #2: name % #3: pre % #4: mid % #5: post -\def\@trnslt@print@dictionary@for#1#2#3#4#5{% +\newcommand*\@trnslt@print@dictionary@for[5]{% \forlistcsloop {\@trnslt@print@dictionary@entry{#3}{#4}{#5}} {@trnslt@dictionary@#2@\@trnslt@language{#1}}% @@ -521,16 +634,29 @@ % #1: pre % #2: mid % #3: post -% #4: {key}{translation} -\def\@trnslt@print@dictionary@entry#1#2#3#4{% - \@trnslt@print@dictionary@entry@aux{#1}{#2}{#3}#4} +% #4: (key)(translation) +\newcommand*\@trnslt@print@dictionary@entry[4]{% + \@trnslt@print@dictionary@entry@aux{#1}{#2}{#3}#4% +} % #1: pre % #2: mid % #3: post % #4: key % #5: translation -\def\@trnslt@print@dictionary@entry@aux#1#2#3#4#5{#1#4#2#5#3} +\newcommand*\@trnslt@print@dictionary@entry@aux[5]{#1#4#2#5#3} + +% ========================================================================== +% Now that the package is finished let's us ethe above commands to provide a +% basis for usage; we need all languages known to `babel' and `polyglossia' +% as well as aliases to allow different spellings/names; we also need dialects +% where it makes sense (e.g. British as a dialect of English) + +% -------------------------------------------------------------------------- +% dummy language `fallback' -- it is needed for the whole mechansim provided +% earlier (\DeclareFallbackTranslation...) +\DeclareLanguage{fallback} +\DeclareLanguageAlias{Fallback}{fallback} % -------------------------------------------------------------------------- % predefined languages @@ -762,8 +888,8 @@ \DeclareLanguageAlias {northern sami}{north sami} \DeclareLanguageAlias {Northern Sami}{northern sami} \DeclareLanguageAlias {Sanskrit}{sanskrit} -% this one isn't needed, or is it? -% \DeclareLanguageAlias {Serbocroatian}{serbocroatian} +% this one isn't needed, or is it? vvv +\DeclareLanguageAlias {Serbocroatian}{serbocroatian} \DeclareLanguageAlias {serbo-croatian}{serbocroatian} \DeclareLanguageAlias {Serbo-Croatian}{serbocroatian} \DeclareLanguageDialect{serbian}{serbocroatian} @@ -807,6 +933,9 @@ \DeclareLanguageAlias {Vietnamese}{vietnamese} \DeclareLanguageAlias {Welsh}{welsh} +% ========================================================================== +% OK, we have everything, do we? No, wait: let's load the basic dictionary +% that is part of this package if it is available for the document language % -------------------------------------------------------------------------- % load basic dictionary if available \AtBeginDocument{% @@ -835,7 +964,7 @@ \endinput -% -------------------------------------------------------------------------- +% ========================================================================== % HISTORY: 2012/09/30 v0.2beta - first version (as part of the `exsheets' bundle) 2012/10/05 v0.2 - \LoadDictionary and \LoadDictionaryFor added and loads of @@ -867,7 +996,7 @@ - new command \PrintDictionaryFor - redefined conditionals; they still seemed to make trouble in some cases -2013/08/05 v1.1 - added /loads/ of languages, noe the list of babel and +2013/08/05 v1.1 - added /loads/ of languages, now the list of babel and polyglossia languages hopefully is complete - a few languages had falsely been declared as dialect instead of an alias @@ -879,4 +1008,13 @@ doesn't exist load it for the corresponding base language instead 2013/09/30 v1.1a - Bug fix in \NewTranslation und \RenewTranslation +2014/01/10 v1.2 - \ifcurrentlanguage, \ifcurrentbaselanguage + - require cnltx-base + - change the `no language package' warning into an info + - \ProvideTranslation + - \NewDictTranslation, \RenewDictTranslation, + \ProvideDictTranslation + - translations in dictionaries are provided + - \baselanguagename + |