| 1 |
# Region (Numeric) Support for datatool v3.0+ (datatool-regions) |
| 2 |
|
| 3 |
Version 1.0 (2025-03-01) |
| 4 |
|
| 5 |
Author: Nicola L. C. Talbot [dickimaw-books.com](https://www.dickimaw-books.com/) |
| 6 |
|
| 7 |
Licence: LPPL |
| 8 |
|
| 9 |
Home Page: https://github.com/nlct/datatool-regions |
| 10 |
|
| 11 |
Required Packages: |
| 12 |
[datatool](https://ctan.org/pkg/datatool) (3.0+), |
| 13 |
[tracklang](https://ctan.org/pkg/tracklang) (1.6.4+) |
| 14 |
|
| 15 |
|
| 16 |
The `datatool-regions` bundle provides the language-independent |
| 17 |
region ldf files for the `datatool` package (v3.0+). |
| 18 |
The `*.ldf` files should all be placed on TeX's path. |
| 19 |
|
| 20 |
These files don't require any explicit loading. They will |
| 21 |
automatically be input by `datatool-base.sty` (or relevant |
| 22 |
supplementary package) if they are found and required by the |
| 23 |
`tracklang` localisation settings. See the `datatool` v3.0+ |
| 24 |
and `tracklang` user manuals for further details. |
| 25 |
|
| 26 |
The region files deal with defining (if applicable) the currency |
| 27 |
symbol and switching to the region's currency in the region's hook. |
| 28 |
Region files may additionally (if not dependent on the language) set |
| 29 |
the number group and decimal characters, and provide functions for |
| 30 |
parsing numeric dates and times. |
| 31 |
|
| 32 |
Note that `datatool-base.sty` deals with appending the region's hook to |
| 33 |
the applicable language captions hook, if available. |
| 34 |
|
| 35 |
The language support is distributed separately. Any setting that |
| 36 |
depends on _both_ language and region should be supplied with the |
| 37 |
applicable language bundle. This may occur for regions with multiple |
| 38 |
official languages, where the number formatting or date/time parsing |
| 39 |
depends on the language within the region. For example, `datatool-english` |
| 40 |
provides `datatool-en-CA.ldf` and `datatool-en-ZA.ldf` in addition |
| 41 |
to `datatool-english.ldf`. |
| 42 |
|
| 43 |
If a pre-3.0 version of `datatool` is installed, these ldf files |
| 44 |
will be ignored. |
| 45 |
|
| 46 |
Example: |
| 47 |
|
| 48 |
\documentclass{article} |
| 49 |
\usepackage[locales={en-GB}]{datatool-base}% v3.0 |
| 50 |
\begin{document} |
| 51 |
Currency: \DTLdecimaltocurrency{12345.67}{\price}\price. |
| 52 |
|
| 53 |
\DTLmul\result{\price}{-0.5}\result. |
| 54 |
Data type: \DTLgetDataTypeName{\DTLdatumtype{\result}}. |
| 55 |
Numeric value: \DTLdatumvalue{\result}. |
| 56 |
\end{document} |
| 57 |
|
| 58 |
If `datatool-regions` is correctly installed, the result will be: |
| 59 |
|
| 60 |
> Currency: £12,345.67. |
| 61 |
> −£6,172.84. Data type: currency. Numeric value: -6172.835. |
| 62 |
|
| 63 |
In most cases the language and region are not inter-connected. |
| 64 |
This means that you would get the same result (in terms of the |
| 65 |
formatting and parsing of the numbers and currency) for the above with |
| 66 |
`locales={cy-GB}`, `locales={gd-GB}`, `locales={ga-GB}`, |
| 67 |
`locales={sco-GB}`, or simply `locales={GB}`. |
| 68 |
|
| 69 |
The source code is on GitHub at |
| 70 |
[github.com/nlct/datatool-regions](https://github.com/nlct/datatool-regions). |
| 71 |
If you want to add new region files, you can use the Perl script |
| 72 |
`src/createregion.pl` in the GitHub repository. It's an |
| 73 |
interactive command line script that doesn't take any arguments |
| 74 |
and will create a region ldf file based on your responses. |
| 75 |
You can then add the new ldf via a pull request. |
| 76 |
|
| 77 |
See also: |
| 78 |
|
| 79 |
- [`datatool-english` (GitHub)](https://github.com/nlct/datatool-english) |
| 80 |
- [Localisation with datatool v3.0+](https://www.dickimaw-books.com/latex/tracklang/datatool-locale.shtml) |
| 81 |
|
| 82 |
This material is subject to the LaTeX Project Public License. |
| 83 |
See http://www.ctan.org/license/lppl1.3 for the details of that license. |