\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{regions2}[2016/10/06 v1.2 (NLCT) Sample package to test tracklang.sty]

\RequirePackage{tracklang}[2016/10/07]

\DeclareOption*{\TrackLanguageTag{\CurrentOption}}
\ProcessOptions

\newcommand*{\weightunit}{kg}
\newcommand*{\lengthunit}{mm}
\newcommand*{\currencyunit}{EUR}

\newcommand*{\unitname}{units}

\newcommand*{\defaultunits}{%
  \renewcommand*{\weightunit}{kg}%
  \renewcommand*{\lengthunit}{mm}%
  \renewcommand*{\currencyunit}{EUR}%
}

\newcommand*{\RequireRegionsDialect}[1]{%
    \TrackLangRequireDialect
    [\TrackLangRequireResource{\CurrentTrackedTag}%
      \ifx\CurrentTrackedTag\CurrentTrackedLanguage
        \ifx\CurrentTrackedRegion\empty
         \TrackLangAddToCaptions{\defaultunits}%
        \else
          \TrackLangRequireResource{\CurrentTrackedRegion}%
        \fi
      \else
        \TrackLangRequireResource{\CurrentTrackedLanguage}%
      \fi
    ]%
    {regions}{#1}%
}

\AnyTrackedLanguages
{%
  \ForEachTrackedDialect{\this@dialect}{%
    \RequireRegionsDialect\this@dialect
  }%
}
{% no tracked languages, default already set up
}

\endinput
