Skip to content

Commit

Permalink
simplify \iflanguageoption
Browse files Browse the repository at this point in the history
  • Loading branch information
Udi-Fogiel committed May 26, 2024
1 parent 74af565 commit 4029a9c
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 54 deletions.
2 changes: 1 addition & 1 deletion tex/gloss-arabic.ldf
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
% Register default options
\InitializeGlossOptions{arabic}{locale=default,calendar=gregorian,numerals=mashriq,hijricorrection=0,abjadjimnotail=false}
% Register alias options
\SetLanguageAliasValues{arabic}{calendar}{islamic}{hijri}
\SetLanguageAliasValues{arabic}{calendar}{islamic,hijri}

\def\arabicgregmonth@default#1{\ifcase#1%
% Egypt, Sudan, Yemen and Golf states
Expand Down
2 changes: 1 addition & 1 deletion tex/gloss-belarusian.ldf
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
% Register default options
\InitializeGlossOptions{belarusian}{babelshorthands=false,numerals=arabic,spelling=modern}
% Register alias options
\SetLanguageAliasValues{belarusian}{spelling}{classic}{tarask}
\SetLanguageAliasValues{belarusian}{spelling}{classic,tarask}

\ifsystem@babelshorthands
\SetGlossOptions{belarusian}{babelshorthands=true}
Expand Down
4 changes: 2 additions & 2 deletions tex/gloss-chinese.ldf
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
\InitializeGlossOptions{chinese}{variant=cn,numerals=arabic}
%\InitializeGlossOptions{chinese}{variant=tw,numerals=arabic}
% Register alias options
\SetLanguageAliasValues{chinese}{variant}{cn}{simplified}
\SetLanguageAliasValues{chinese}{variant}{tw}{traditional}
\SetLanguageAliasValues{chinese}{variant}{cn,simplified}
\SetLanguageAliasValues{chinese}{variant}{tw,traditional}


\def\chinese@capsformat{%
Expand Down
4 changes: 2 additions & 2 deletions tex/gloss-english.ldf
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@
% Register default options
\InitializeGlossOptions{english}{variant=us,ordinalmonthday=false}
% Register alias options
\SetLanguageAliasValues{english}{variant}{us}{american}
\SetLanguageAliasValues{english}{variant}{uk}{british}
\SetLanguageAliasValues{english}{variant}{us,american}
\SetLanguageAliasValues{english}{variant}{uk,british}

\ifxetex
% Check if \l@english is defined. If not, try to set it to some variety
Expand Down
2 changes: 1 addition & 1 deletion tex/gloss-french.ldf
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
itemlabels=\textemdash,itemlabeli=\textemdash,itemlabelii=\textemdash,
itemlabeliii=\textemdash,itemlabeliv=\textemdash}
% Register alias options
\SetLanguageAliasValues{french}{variant}{canadian}{acadian}
\SetLanguageAliasValues{french}{variant}{canadian,acadian}


\def\french@fontsetup{%
Expand Down
6 changes: 3 additions & 3 deletions tex/gloss-german.ldf
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@
% Register default options
\InitializeGlossOptions{german}{variant=german,spelling=new,script=latin,babelshorthands=false}
% Register alias options
\SetLanguageAliasValues{german}{spelling}{new}{1996}
\SetLanguageAliasValues{german}{spelling}{old}{1901}
\SetLanguageAliasValues{german}{script}{blackletter}{fraktur}
\SetLanguageAliasValues{german}{spelling}{new,1996}
\SetLanguageAliasValues{german}{spelling}{old,1901}
\SetLanguageAliasValues{german}{script}{blackletter,fraktur}

\ifsystem@babelshorthands
\SetGlossOptions{german}{babelshorthands=true}
Expand Down
4 changes: 2 additions & 2 deletions tex/gloss-greek.ldf
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@
% Register default options
\InitializeGlossOptions{greek}{variant=monotonic,numerals=greek}
% Register alias options
\SetLanguageAliasValues{greek}{variant}{monotonic}{mono}
\SetLanguageAliasValues{greek}{variant}{polytonic}{poly}
\SetLanguageAliasValues{greek}{variant}{monotonic,mono}
\SetLanguageAliasValues{greek}{variant}{polytonic,poly}

\def\monogreekcaptions{%
\def\refname{Αναφορές}%
Expand Down
61 changes: 19 additions & 42 deletions tex/polyglossia.sty
Original file line number Diff line number Diff line change
Expand Up @@ -1928,17 +1928,16 @@
\cs_generate_variant:Nn \keys_precompile:nnN { nec }
% Record synonymous keyvals such as variant=us and variant=american
% Syntax: \SetLanguageAliasValues{<lang>}{<key>}{<val>}{<alias vals, comma-separated>}
\NewDocumentCommand \SetLanguageAliasValues { m m m m }
% Syntax: \SetLanguageAliasValues{<lang>}{<key>}{<alias vals, comma-separated>}
\int_new:N \l_xpg_alias_keyvals_int
\int_set:Nn \l_xpg_alias_keyvals_int { 2 }
\NewDocumentCommand \SetLanguageAliasValues { m m m }
{
\prop_if_exist:cF { xpg@alias@keyvals@#1@#3 }
{ \prop_new:c {xpg@alias@keyvals@#1@#3} }
\prop_put:cnn { xpg@alias@keyvals@#1@#3 }
{#2}{#4}
\prop_if_exist:cF { xpg@alias@keyvals@#1@#4 }
{ \prop_new:c {xpg@alias@keyvals@#1@#4} }
\prop_put:cnn { xpg@alias@keyvals@#1@#4 }
{#2}{#3}
\clist_map_inline:nn { #3 }
{
\int_const:cn { c_xpg_alias_keyvals_#1_#2_##1_int } { \l_xpg_alias_keyvals_int }
}
\int_incr:N \l_xpg_alias_keyvals_int
}
\cs_new:Npn \xpg__keyval_parser:nnN #1 #2 #3 % #1 = key-vals, #2 = language, #3 = prop
Expand All @@ -1963,38 +1962,16 @@
}
\prg_set_conditional:Npnn \__xpg_check_option_value:NNN #1#2#3 { p , T , F , TF }
{
\prop_get:NnNTF \l_xpg_curropt_prop { #1 / #2 } \l_tmpa_tl
{
\str_if_eq:eeTF{\l_tmpa_tl}{#3}
{\prg_return_true:}
{
\cs_if_exist:cTF {xpg@alias@keyvals@#1@#3}
{
\prop_get:cnNTF {xpg@alias@keyvals@#1@#3} {#2} \l_tmpb_tl
{
\clist_set:Ne{\l_tmpa_clist}{\l_tmpb_tl}
\bool_if_exist:NF \l__xpg_val_found_bool
{ \bool_new:N \l__xpg_val_found_bool }
\bool_set_false:N \l__xpg_val_found_bool
\clist_map_inline:Nn \l_tmpa_clist {
\str_if_eq:eeT{##1}{\l_tmpa_tl}
{ \bool_set_true:N \l__xpg_val_found_bool }
}
\bool_if:nTF \l__xpg_val_found_bool
{ \prg_return_true: }
{ \prg_return_false: }
}
{
\prg_return_false:
}
} { \prg_return_false: }
}
}
{
\prg_return_false:
}
}
{
\int_compare:nNnTF
{
\cs_if_exist_use:cF { c_xpg_alias_keyvals_#1_#2_#3_int } { 0 }
} =
{
\cs_if_exist_use:cF { c_xpg_alias_keyvals_#1_#2_\prop_item:Nn \l_xpg_curropt_prop { #1 / #2 }_int } { 1 }
}
{ \prg_return_true: } { \prg_return_false: }
}
\prg_set_conditional:Npnn \xpg_if_main_language:n #1 { T, F, TF }
{
Expand Down

0 comments on commit 4029a9c

Please sign in to comment.