Debian Codegraph @

texmf-dist/source/latex/siunitx/siunitx-locale.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: siunitx-locale.dtx Copyright (C) 2020-2024,2026 Joseph Wright
4 %
5 % It may be distributed and/or modified under the conditions of the
6 % LaTeX Project Public License (LPPL), either version 1.3c of this
7 % license or (at your option) any later version. The latest version
8 % of this license is in the file
9 %
10 % https://www.latex-project.org/lppl.txt
11 %
12 % This file is part of the "siunitx bundle" (The Work in LPPL)
13 % and all files in that bundle must be distributed together.
14 %
15 % The released version of this bundle is available from CTAN.
16 %
17 % -----------------------------------------------------------------------
18 %
19 % The development version of the bundle can be found at
20 %
21 % https://github.com/josephwright/siunitx
22 %
23 % for those people who are interested.
24 %
25 % -----------------------------------------------------------------------
26 %
27 %<*driver>
28 \documentclass{l3doc}
29 % Additional commands needed in this source
30 \ProvideDocumentCommand\email{m}{\href{mailto:#1}{\nolinkurl{#1}}}
31 % The next line is needed so that \GetFileInfo will be able to pick up
32 % version data
33 \usepackage{siunitx}
34 \begin{document}
35 \DocInput{\jobname.dtx}
36 \end{document}
37 %</driver>
38 % \fi
39 %
40 % \GetFileInfo{siunitx.sty}
41 %
42 % \title{^^A
43 % \pkg{siunitx-locale} -- Localization^^A
44 % \thanks{This file describes \fileversion,
45 % last revised \filedate.}^^A
46 % }
47 %
48 % \author{^^A
49 % Joseph Wright^^A
50 % \thanks{^^A
51 % E-mail:
52 % \email{[email protected]}^^A
53 % }^^A
54 % }
55 %
56 % \date{Released \filedate}
57 %
58 % \maketitle
59 %
60 % \begin{documentation}
61 %
62 % \section{Localization}
63 %
64 % This submodule is concerned with localization of \pkg{siunitx} output
65 % based on the locale. If the \pkg{translations} package is available, this
66 % is loaded here and used to provide various fixed strings for output.
67 %
68 % \begin{function}{locale}
69 % \begin{syntax}
70 % |locale| = \meta{locale}
71 % \end{syntax}
72 % Selects the \meta{locale} used to apply standard settings for other
73 % keys, principally |exponent-product|, |inter-unit-product|
74 % and |output-decimal-marker|.
75 % \end{function}
76 %
77 % \end{documentation}
78 %
79 % \begin{implementation}
80 %
81 % \section{\pkg{siunitx-locale} implementation}
82 %
83 % Start the \pkg{DocStrip} guards.
84 % \begin{macrocode}
85 %<*package>
86 % \end{macrocode}
87 %
88 % Identify the internal prefix.
89 % \begin{macrocode}
90 %<@@=siunitx_locale>
91 % \end{macrocode}
92 %
93 % \subsection{Locales}
94 %
95 % The basics for defining locales are easy: these are just meta keys.
96 % \begin{macrocode}
97 \keys_define:nn { siunitx }
98 {
99 locale .choice: ,
100 locale / BR .meta:n =
101 {
102 exponent-product = \times ,
103 inter-unit-product = \, ,
104 output-decimal-marker = { , }
105 } ,
106 locale / DE .meta:n =
107 {
108 exponent-product = \cdot ,
109 inter-unit-product = \, ,
110 output-decimal-marker = { , }
111 } ,
112 locale / FR .meta:n =
113 {
114 exponent-product = \times ,
115 inter-unit-product = \, ,
116 output-decimal-marker = { , }
117 } ,
118 locale / IT .meta:n =
119 {
120 exponent-product = \times ,
121 inter-unit-product = \, ,
122 output-decimal-marker = { , }
123 } ,
124 locale / PL .meta:n =
125 {
126 exponent-product = \cdot ,
127 inter-unit-product = \cdot ,
128 output-decimal-marker = { , }
129 } ,
130 locale / SI .meta:n =
131 {
132 exponent-product = \times ,
133 inter-unit-product = \, ,
134 output-decimal-marker = { , }
135 } ,
136 locale / UK .meta:n =
137 {
138 exponent-product = \times ,
139 inter-unit-product = \, ,
140 output-decimal-marker = .
141 },
142 locale / US .meta:n =
143 {
144 exponent-product = \times ,
145 inter-unit-product = \, ,
146 output-decimal-marker = .
147 } ,
148 locale / ZA .meta:n =
149 {
150 exponent-product = \times ,
151 inter-unit-product = \cdot ,
152 output-decimal-marker = { , }
153 }
154 }
155 % \end{macrocode}
156 %
157 % \subsection{Localisation}
158 %
159 % Localisation makes use of the \pkg{translations} package. This only happens
160 % if it is available, and is transparent to the user.
161 % \begin{macrocode}
162 \file_if_exist:nT { translations.sty }
163 {
164 \RequirePackage { translations }
165 \DeclareTranslation { Catalan } { and } { i }
166 \DeclareTranslation { Italian } { and } { e }
167 \DeclareTranslation { Portuguese } { and } { e }
168 \DeclareTranslation { Slovene } { and } { in }
169 \DeclareTranslation { Italian } { from~(numerical~range) } { da }
170 \DeclareTranslation { Brazilian } { to~(numerical~range) } { a }
171 \DeclareTranslation { Catalan } { to~(numerical~range) } { a }
172 \DeclareTranslation { English } { to~(numerical~range) } { to }
173 \DeclareTranslation { French } { to~(numerical~range) } { à }
174 \DeclareTranslation { German } { to~(numerical~range) } { bis }
175 \DeclareTranslation { Italian } { to~(numerical~range) } { a }
176 \DeclareTranslation { Polish } { to~(numerical~range) } { do }
177 \DeclareTranslation { Portuguese } { to~(numerical~range) } { a }
178 \DeclareTranslation { Slovene } { to~(numerical~range) } { do }
179 \DeclareTranslation { Spanish } { to~(numerical~range) } { a }
180 \keys_set:nn { siunitx }
181 {
182 list-final-separator =
183 {
184 \TextOrMath { \space } { \ }
185 \text { \GetTranslation { and } }
186 \TextOrMath { \space } { \ }
187 } ,
188 list-pair-separator =
189 {
190 \TextOrMath { \space } { \ }
191 \text { \GetTranslation { and } }
192 \TextOrMath { \space } { \ }
193 } ,
194 range-open-phrase =
195 {
196 \bool_lazy_or:nnF
197 {
198 \tl_if_blank_p:e
199 { \GetTranslation { from~(numerical~range) } }
200 }
201 {
202 \str_if_eq_p:ee
203 { \GetTranslation { from~(numerical~range) } }
204 { from~(numerical~range) }
205 }
206 {
207 \text { \GetTranslation { from~(numerical~range) } }
208 \TextOrMath { \space } { \ }
209 }
210 } ,
211 range-phrase =
212 {
213 \TextOrMath { \space } { \ }
214 \text { \GetTranslation { to~(numerical~range) } }
215 \TextOrMath { \space } { \ }
216 }
217 }
218 }
219 % \end{macrocode}
220 %
221 % \end{implementation}
222 %
223 % \PrintIndex