Skip to content

Commit

Permalink
version 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
cgnieder committed Jun 7, 2016
1 parent 7274c18 commit 2075c1b
Show file tree
Hide file tree
Showing 11 changed files with 296 additions and 171 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--------------------------------------------------------------------------
the CHEMMACROS package v5.6a 2016/05/04
the CHEMMACROS package v5.7 2016/06/07

comprehensive support for typesetting chemistry documents

Expand Down
23 changes: 5 additions & 18 deletions chemmacros.module.acid-base.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
\ChemModule{acid-base}{2016/04/27 acid/base}
\ChemModule{acid-base}{2016/05/31 acid/base}

\chemmacros_load_modules:n {charges}

Expand Down Expand Up @@ -66,7 +66,9 @@
\tl_set:cn
{l__chemmacros_#2_tl}
{ \chemmacros_translate:n {#2} }
\DeclareTranslationFallback {#2} {#3}
\chemmacros_if_compatiblity:nnTF {>} {5.6}
{ \chemmacros_declare_translation:nnn {#2} {fallback} {#3} }
{ \DeclareTranslationFallback {#2} {#3} }
\cs_set_protected:Npn #1
{
\ensuremath
Expand Down Expand Up @@ -150,28 +152,13 @@
\ChemCompatibilityFrom{5.6}
\chemmacros_declare_translations:nn {K-acid}
{
fallback = \mathrm {a} ,
English = \mathrm {a} ,
German = \mathrm {s} ,
Dutch = \mathrm {z}
}

\chemmacros_declare_translations:nn {K-base}
{
fallback = \mathrm {b} ,
English = \mathrm {b} ,
German = \mathrm {b}
}

\chemmacros_declare_translations:nn {K-water}
{
fallback = \mathrm {w} ,
English = \mathrm {w} ,
German = \mathrm {w}
}
\EndChemCompatibility
% --------------------------------------------------------------------------
\tex_endinput:D

2016/02/04 - \NewChemEqConstant and family, new option `eq-constant'
2016/04/27 - moved translations from lang module to acid-base module
2016/05/31 - adapt to changes in `lang' module
15 changes: 13 additions & 2 deletions chemmacros.module.errorcheck.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
\ChemModule{errorcheck}{2016/03/08 error checking for unloaded modules}[5.2]
\ChemModule{errorcheck}{2016/05/31 error checking for unloaded modules}[5.2]

\RequirePackage{scrlfile}

\msg_new:nnn {chemmacros} {undefined}
{ The~ #1~ `#2'~ is~ undefined.~ You~ need~ to~ load~ the~ `#3'~ module. }
Expand Down Expand Up @@ -98,6 +100,15 @@
\chemmacros_command_requires_module:Nn \schemename {scheme}
\chemmacros_command_requires_module:Nn \listofschemes {scheme}

\BeforePackage {chemscheme}
{
\cs_undefine:N \scheme
\cs_undefine:N \endscheme
\cs_undefine:N \listschemename
\cs_undefine:N \schemename
\cs_undefine:N \listofschemes
}

% spectroscopy module
\chemmacros_command_requires_module:Nn \NMR {spectroscopy}
\chemmacros_environment_requires_module:nn {experimental} {spectroscopy}
Expand All @@ -117,4 +128,4 @@

2015/10/14 - first version
2016/03/08 - add `polymers' module

2016/05/31 - enable `chemscheme' to be loaded after chemmacros
55 changes: 46 additions & 9 deletions chemmacros.module.lang.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
\ChemModule{lang}{2016/04/27 language settings for chemmacros}
\ChemModule{lang}{2016/05/31 language settings for chemmacros}

\RequirePackage{translations}

Expand All @@ -43,16 +43,25 @@
% this token list will hold the chosen language for chemmacros; since the
% language is either chosen automatically or by option it is only available at
% begin document
\tl_new:N \l_chemmacros_language_tl
\tl_set:Nn \l_chemmacros_language_tl {english}
\tl_new:N \l__chemmacros_current_language_tl
\tl_new:N \l_chemmacros_language_tl
\tl_set:Nn \l_chemmacros_language_tl {english}
\tl_new:N \l__chemmacros_current_language_tl

\tl_const:Nx \c__chemmacros_keyword_prefix_tl
{ \chemmacros_if_compatiblity:nnT {>} {5.6} {chem-keyword-} }

\prop_new:N \g_chemmacros_translations_prop

% translate the key #1
\cs_new:Npn \chemmacros_translate:n #1
{
\bool_if:NTF \l__chemmacros_language_auto_bool
{ \GetTranslation {#1} }
{ \GetTranslationFor {\l_chemmacros_language_tl} {#1} }
{ \GetTranslation { \c__chemmacros_keyword_prefix_tl #1 } }
{
\GetTranslationFor
{\l_chemmacros_language_tl}
{ \c__chemmacros_keyword_prefix_tl #1 }
}
}

\DeclareExpandableDocumentCommand \ChemTranslate {m}
Expand Down Expand Up @@ -93,16 +102,16 @@
}

% --------------------------------------------------------------------------
\ChemCompatibilityFrom{5.6}
% \ChemCompatibilityFrom{5.6}
\cs_new_protected:Npn \__chemmacros_declare_translation:nw #1#2=#3\q_stop
{
\tl_set:Nx \l__chemmacros_tmpa_tl { \tl_trim_spaces:n {#2} }
\tl_set:Nx \l__chemmacros_tmpb_tl { \tl_trim_spaces:n {#3} }
\use:x
{
\chemmacros_declare_translation:nnn
{ \exp_not:V \l__chemmacros_tmpa_tl }
{ \exp_not:n {#1} }
{ \exp_not:V \l__chemmacros_tmpa_tl }
{ \exp_not:V \l__chemmacros_tmpb_tl }
}
}
Expand All @@ -111,7 +120,15 @@
% #2: lang
% #3: translation
\cs_new_protected:Npn \chemmacros_declare_translation:nnn #1#2#3
{ \DeclareTranslation {#1} {#2} {#3} }
{
% TODO: this should be \declaretranslation
\@trnslt@declare@translation
{ \c__chemmacros_keyword_prefix_tl #1 }
{#2}
{#3}
\prop_gput:Nnn \g_chemmacros_translations_prop {#1(#2)} {#3}
}
\cs_generate_variant:Nn \chemmacros_declare_translation:nnn {V}

% #1: key
% #2: csv list: { <lang1> = <translation1> , <lang2> = <translation2> }
Expand All @@ -128,6 +145,23 @@
\NewDocumentCommand \DeclareChemTranslation {mmm}
{ \chemmacros_declare_translation:nnn {#1} {#2} {#3} }
\@onlypreamble \DeclareChemTranslation
% \EndChemCompatibility

\cs_new:Npn \__chemmacros_parse_translate_list_entry:nnn #1#2#3 {}

\cs_new_protected:Npn \__chemacros_parse_translate_list_entry:www #1(#2)\q_mark#3\q_stop
{ \__chemmacros_parse_translate_list_entry:nnn {#1} {#2} {#3} }

\cs_new_protected:Npn \chemmacros_for_all_translations_do:n #1
{
\cs_set:Npn \__chemmacros_parse_translate_list_entry:nnn ##1##2##3 {#1}
\prop_map_inline:Nn \g_chemmacros_translations_prop
{ \__chemacros_parse_translate_list_entry:www ##1 \q_mark ##2 \q_stop }
}

\ChemCompatibilityFrom{5.7}
\NewDocumentCommand \ForAllChemTranslationsDo {+m}
{ \chemmacros_for_all_translations_do:n {#1} }
\EndChemCompatibility

% --------------------------------------------------------------------------
Expand All @@ -141,3 +175,6 @@
- \DeclareChemTranslation and \DeclareChemTranslations
- moved translations from lang module to the corresponding modules
they belong to
2016/05/31 - add prefix string to translation keywords
- add logging of translation keywords
- \ForAllChemTranslationsDo
Loading

0 comments on commit 2075c1b

Please sign in to comment.