\href{https://travis-ci.org/yargs/y18n}{\texttt{ }} \href{https://coveralls.io/github/yargs/y18n}{\texttt{ }} \href{https://npmjs.org/package/y18n}{\texttt{ }} \href{https://github.com/feross/standard}{\texttt{ }} \href{https://conventionalcommits.org}{\texttt{ }}

The bare-\/bones internationalization library used by yargs.

Inspired by \href{https://www.npmjs.com/package/i18n}{\texttt{ i18n}}.\hypertarget{md_sfcode_node_modules_y18n_README_autotoc_md34376}{}\doxysection{Examples}\label{md_sfcode_node_modules_y18n_README_autotoc_md34376}
{\itshape simple string translation\+:}


\begin{DoxyCode}{0}
\DoxyCodeLine{var \_\_ = require('y18n').\_\_}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(\_\_('my awesome string \%s', 'foo')) }

\end{DoxyCode}


output\+:

{\ttfamily my awesome string foo}

{\itshape using tagged template literals}


\begin{DoxyCode}{0}
\DoxyCodeLine{var \_\_ = require('y18n').\_\_}
\DoxyCodeLine{var str = 'foo'}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(\_\_`my awesome string \$\{str\}`) }

\end{DoxyCode}


output\+:

{\ttfamily my awesome string foo}

{\itshape pluralization support\+:}


\begin{DoxyCode}{0}
\DoxyCodeLine{var \_\_n = require('y18n').\_\_n}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(\_\_n('one fish \%s', '\%d fishes \%s', 2, 'foo')) }

\end{DoxyCode}


output\+:

{\ttfamily 2 fishes foo}\hypertarget{md_sfcode_node_modules_y18n_README_autotoc_md34377}{}\doxysection{JSON Language Files}\label{md_sfcode_node_modules_y18n_README_autotoc_md34377}
The JSON language files should be stored in a {\ttfamily ./locales} folder. File names correspond to locales, e.\+g., {\ttfamily en.\+json}, {\ttfamily pirate.\+json}.

When strings are observed for the first time they will be added to the JSON file corresponding to the current locale.\hypertarget{md_sfcode_node_modules_y18n_README_autotoc_md34378}{}\doxysection{Methods}\label{md_sfcode_node_modules_y18n_README_autotoc_md34378}
\hypertarget{md_sfcode_node_modules_y18n_README_autotoc_md34379}{}\doxysubsection{require(\textquotesingle{}y18n\textquotesingle{})(config)}\label{md_sfcode_node_modules_y18n_README_autotoc_md34379}
Create an instance of y18n with the config provided, options include\+:


\begin{DoxyItemize}
\item {\ttfamily directory}\+: the locale directory, default {\ttfamily ./locales}.
\item {\ttfamily update\+Files}\+: should newly observed strings be updated in file, default {\ttfamily true}.
\item {\ttfamily locale}\+: what locale should be used.
\item {\ttfamily fallback\+To\+Language}\+: should fallback to a language-\/only file (e.\+g. {\ttfamily en.\+json}) be allowed if a file matching the locale does not exist (e.\+g. {\ttfamily en\+\_\+\+US.\+json}), default {\ttfamily true}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_y18n_README_autotoc_md34380}{}\doxysubsection{y18n.\+\_\+\+\_\+(str, arg, arg, arg)}\label{md_sfcode_node_modules_y18n_README_autotoc_md34380}
Print a localized string, {\ttfamily s} will be replaced with {\ttfamily arg}s.

This function can also be used as a tag for a template literal. You can use it like this\+: {\ttfamily \+\_\+\+\_\+\&\#96;hello \$\{\textquotesingle{}world\textquotesingle{}\}\&\#96;}. This will be equivalent to `\+\_\+\+\_\+(\textquotesingle{}hello s', \textquotesingle{}world\textquotesingle{})\`{}.\hypertarget{md_sfcode_node_modules_y18n_README_autotoc_md34381}{}\doxysubsection{y18n.\+\_\+\+\_\+n(singular\+String, plural\+String, count, arg, arg, arg)}\label{md_sfcode_node_modules_y18n_README_autotoc_md34381}
Print a localized string with appropriate pluralization. If {\ttfamily d} is provided in the string, the {\ttfamily count} will replace this placeholder.\hypertarget{md_sfcode_node_modules_y18n_README_autotoc_md34382}{}\doxysubsection{y18n.\+set\+Locale(str)}\label{md_sfcode_node_modules_y18n_README_autotoc_md34382}
Set the current locale being used.\hypertarget{md_sfcode_node_modules_y18n_README_autotoc_md34383}{}\doxysubsection{y18n.\+get\+Locale()}\label{md_sfcode_node_modules_y18n_README_autotoc_md34383}
What locale is currently being used?\hypertarget{md_sfcode_node_modules_y18n_README_autotoc_md34384}{}\doxysubsection{y18n.\+update\+Locale(obj)}\label{md_sfcode_node_modules_y18n_README_autotoc_md34384}
Update the current locale with the key value pairs in {\ttfamily obj}.\hypertarget{md_sfcode_node_modules_y18n_README_autotoc_md34385}{}\doxysection{License}\label{md_sfcode_node_modules_y18n_README_autotoc_md34385}
ISC 