% ---------------------------------------------------------------------------------------
% subfile of pgf-PeriodicTable package -----------------------------------------------
% ---------------------------------------------------------------------------------------
\def\pgfPT@library@override@loaded{}%
\message{pgfPT override loaded!}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% provide the macros
%
%       \pgfPToverrideacros[language flag]{override list}
%       \pgfPTrestoreacros[language flag]{override list}
%       \pgfPToverridenames[language flag]{override list}
%       \pgfPTrestorenames[language flag]{override list}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter%
% \pgfPToverrideacros[language flag]{override list}
% ---------------------------------------------------------------------------------------
% macro to replace the 'default' acronyms by the ones provided in 'override list'
% ---------------------------------------------------------------------------------------
% optional: language flag. If not provided default language is used.
% mandatory: override list, is a comma separated list of the form what/new acronym
\def\pgfPToverrideacros{\@ifnextchar[{\pgfPT@overrideacros}{\pgfPT@overrideacros[\pgfPT@defaultLanguage]}}%
\def\pgfPT@overrideacros[#1]#2{\ignorespaces%
\pgfPT@validLang{#1}%
\ifx\pgfPT@langOK\undefined\relax%
    \PackageError{pgfPT}{overrideacros: invalid language flag '#1'. It will be ignored...}{}%
\else%
\pgfPT@overrideacrostrue%
\edef\@pgfPT@customacro@langflag{#1}%
\def\@pgfPT@getcustomacro@info##1/##2\relax{\edef\@pgfPT@customacro@what{##1}\edef\@pgfPT@customacro@theacro{##2}}%
\def\@pgfPT@acro@extract##1/##2\relax{\edef\@pgfPT@acro@i{##1}\edef\@pgfPT@acro@ii{##2}}%
\def\@pgfPT@replaceacro##1##2{\ignorespaces% ##1 -> what ##2 -> new acro
    \expandafter\let\expandafter\@pgfPT@replaceacro@copy\csname pgfPT@acr@\@pgfPT@customacro@what\endcsname\relax%
    \pgfPT@countf=0\relax%
    \@for\@pgfPT@list@i:=\@pgfPT@replaceacro@copy\do{%
            \advance\pgfPT@countf by1\relax%
            \expandafter\@pgfPT@acro@extract\@pgfPT@list@i\relax%
            \ifx\@pgfPT@acro@ii\@pgfPT@customacro@langflag\relax
                \expandafter\edef\csname pgfPT@acronewlist\@roman\pgfPT@countf\endcsname{\@pgfPT@customacro@theacro/\@pgfPT@acro@ii}%
            \else%
                \expandafter\edef\csname pgfPT@acronewlist\@roman\pgfPT@countf\endcsname{\@pgfPT@acro@i/\@pgfPT@acro@ii}%
            \fi%
            }% end do
            \expandafter\ifx\csname pgfPT@acr@##1@original\@pgfPT@customacro@langflag\endcsname\relax%
                \expandafter\edef\csname pgfPT@acr@##1@original\@pgfPT@customacro@langflag\endcsname{\csname pgfPT@acr@##1\endcsname}\relax\fi%
    \@for\@pgfPT@tmpcount:={8,7,6,5,4,3,2,1}\do{%
            \ifnum\@pgfPT@tmpcount<8\relax% \csname pgfPT@acronewlist\@roman\pgfPT@countf\endcsname
                \expandafter\edef\csname pgfPT@acr@##1\endcsname{\csname pgfPT@acronewlist\@roman\@pgfPT@tmpcount\endcsname,\csname pgfPT@acr@##1\endcsname}\relax%
            \else%
                \expandafter\edef\csname pgfPT@acr@##1\endcsname{\csname pgfPT@acronewlist\@roman\@pgfPT@tmpcount\endcsname}\relax%
            \fi%
            }%
    }% end \@pgfPT@replaceacro
\@for\@pgfPT@tmplist:=#2\do{\ignorespaces%
        \expandafter\@pgfPT@getcustomacro@info\@pgfPT@tmplist\relax%
        \pgfPT@validate@cell@content{\@pgfPT@customacro@what}%
        \ifpgfPT@found% valid entry
            \@pgfPT@replaceacro{\@pgfPT@customacro@what}{\@pgfPT@customacro@theacro}%
        \else%
            \PackageError{pgfPT}{overrideacros: unknown cell content '\@pgfPT@customacro@what'. It will be ignored...}{}%
        \fi% valid entry
        }% end do
\fi% language OK
}% END \pgfPToverrideacros
%
%
% \pgfPTrestoreacros[language flag]{restore list}
% ---------------------------------------------------------------------------------------
% macro to restore the 'default' names in 'restore list'
% ---------------------------------------------------------------------------------------
% optional: language flag. If not provided default language is used.
% mandatory: restore list, is a comma separated list of what's
\def\pgfPTrestoreacros{\@ifnextchar[{\pgfPT@restoreacros}{\pgfPT@restoreacros[\pgfPT@defaultLanguage]}}%
\def\pgfPT@restoreacros[#1]#2{%
\@for\@pgfPT@tmplist:=#2\do{\ignorespaces%
        \pgfPT@validate@cell@content{\@pgfPT@tmplist}%
        \ifpgfPT@found% valid entry
            \edef\@pgfPT@customacro@langflag{#1}%
            \expandafter\ifx\csname pgfPT@acr@\@pgfPT@tmplist @original\@pgfPT@customacro@langflag\endcsname\undefined\relax\else%
            \expandafter\edef\csname pgfPT@acr@\@pgfPT@tmplist\endcsname{\csname pgfPT@acr@\@pgfPT@tmplist @original\@pgfPT@customacro@langflag\endcsname}\relax%
            \expandafter\let\csname pgfPT@acr@\@pgfPT@tmplist @original\@pgfPT@customacro@langflag\endcsname\relax%
            \fi%
        \else%
            \PackageError{pgfPT}{restoreacros: unknown cell content '\@pgfPT@tmplist'. It will be ignored...}{}%
        \fi% valid entry
        }% end do
}% END \pgfPTrestoreacros
%
%
% \pgfPToverridenames[language flag]{override list}
% ---------------------------------------------------------------------------------------
% macro to replace the 'default' names by the ones provided in 'override list'
% ---------------------------------------------------------------------------------------
% optional: language flag. If not provide default language is used.
% mandatory: override list, is a comma separated list of the form Z/new name
\def\pgfPToverridenames{\@ifnextchar[{\pgfPT@overridenames}{\pgfPT@overridenames[\pgfPT@defaultLanguage]}}%
\def\pgfPT@overridenames[#1]#2{\ignorespaces%
\def\@pgfPT@overridenames@true{}%
\ifx#2\pgfPT@relax\relax\PackageWarning{pgfPT}{overridenames: the override list is empty. Nothing will be changed!}\relax%
\else% NOT EMPTY #2
    \foreach \pgfPT@overnames@Z/\pgfPT@overnames@name in {#2}{%
        \edef\pgfPT@overnames@cur{\csname pgfPT@nomes@\@roman{\pgfPT@overnames@Z}\endcsname}%
        \expandafter\ifx\csname pgfPT@nomes@\@roman{\pgfPT@overnames@Z}@copy\endcsname\relax%
        \global\expandafter\let\csname pgfPT@nomes@\@roman{\pgfPT@overnames@Z}@copy\endcsname\pgfPT@overnames@cur\relax
        \fi%
        \edef\@pgfPT@customname@langflag{#1}%
        \@for\@pgfPT@tmplang:=\pgfPT@languagesList\do{%
            \pgfPT@setnames[\@pgfPT@tmplang]{\pgfPT@overnames@Z}%
            \ifx\@pgfPT@customname@langflag\@pgfPT@tmplang\relax%
            \expandafter\edef\csname tmp@\@pgfPT@tmplang\endcsname{\pgfPT@overnames@name}%
            \else%
            \expandafter\edef\csname tmp@\@pgfPT@tmplang\endcsname{\csname pgfPTdata@name@\@roman{\pgfPT@overnames@Z}@\@pgfPT@tmplang\endcsname}%
            \fi%
        }% end do
        \edef\pgfPT@nomes@i@tmmp{\tmp@pt/pt,\tmp@en/en,\tmp@fr/fr,\tmp@de/de,\tmp@it/it,\tmp@es/es,\tmp@br/br,\tmp@user/user}%
        \global\expandafter\let\csname pgfPT@nomes@\@roman{\pgfPT@overnames@Z}\endcsname\pgfPT@nomes@i@tmmp\relax%
    }%
\fi%
}% END \pgfPToverridenames
%
%
% \pgfPTrestorenames[language flag]{restore list}
% ---------------------------------------------------------------------------------------
% macro to restore the 'default' names in 'restore list'
% ---------------------------------------------------------------------------------------
% optional: language flag. If not provide default language is used.
% mandatory: restore list, is a comma separated list of Z's
\def\pgfPTrestorenames{\@ifnextchar[{\pgfPT@restorenames}{\pgfPT@restorenames[\pgfPT@defaultLanguage]}}%
\def\pgfPT@restorenames[#1]#2{\ignorespaces%
\ifx\@pgfPT@overridenames@true\undefined\relax\else%
    \ifx#2\pgfPT@relax\relax\PackageWarning{pgfPT}{The restore list is empty. Nothing will be changed!}\relax%
    \else% NOT EMPTY #2 %
    \@for\pgfPT@restorenames@Z:=#2\do{%
    \edef\pgfPT@originalname{\csname pgfPT@nomes@\@roman{\pgfPT@restorenames@Z}@copy\endcsname}\relax%
        \if\pgfPT@originalname\empty\relax%
        \PackageWarning{pgfPT}{restorenames: the name of element with Z=\pgfPT@restorenames@Z\space in #1\space was not changed previously. Ignoring restore...}%
        \else%
        \global\expandafter\let\csname pgfPT@nomes@\@roman{\pgfPT@restorenames@Z}\endcsname\pgfPT@originalname\relax%
        \fi%
    }%
    \fi%
\fi%
}% END \pgfPTrestorenames
\makeatother%
\endinput
