anLocales
anLocales β a cross-platform Rust library for working with locales, similar to glibc-locales, but simpler and with C API support.
- Supports LC_TIME, LC_NUMERIC, LC_MONETARY, LC_COLLATE, plural rules
- Date/number formats in
data_format.json - Interface strings in
locale.toml - Caching in
temp/ - C API compatible (
.so/.dll)
π Locale Directory Structure
Linux/macOS:
/usr/share/anlocales/
ββ locales/
β ββ ru_RU/
β β ββ data_format.json
β β ββ locale.toml
β ββ en_US/
ββ temp/ # cache
ββ settings.json # default_locale, fallback_locale
Windows:
C:\ProgramData\anlocales\
ββ locales\
β ββ ru_RU\
β β ββ data_format.json
β β ββ locale.toml
β ββ en_US\
ββ temp\ # cache
ββ settings.json # default_locale, fallback_locale
Example data_format.json:
Example locale.toml:
= ["Settings"]
= ["Exit"]
= ["Hello"]
β‘ Quick Start (Rust)
use AnLocales;
use NaiveDate;
π Using from C
int
π Building
*nix
# Outputs:
# dist/libanLocales.so # Linux
# dist/libanLocales.dylib # macOS
Windows
# Outputs:
# target/x86_64-pc-windows-gnu/release/anLocales.dll
# you can run "make" but if its not working use this method
Installing anLocales Library
To enable localization in some programs using this library, you need the anLocales library. Follow the instructions for your platform:
1. Download or build the library
I think you already build the library, but if not, you can download from artifacts, or follow the instructions from building guide
- After building, you will have one of the compiled libraries (depending on the platform):
- Linux:
libanLocales.so - macOS:
libanLocales.dylib - Windows:
anLocales.dll
- Linux:
2. Place the library
-
Move or copy the library to a folder in your systemβs library path. Examples:
-
Linux/macOS:
-
Windows:
- Copy
anLocales.dllto a folder in%PATH%.
- Copy
-
π‘ Tip: On Linux/macOS, if the library is not found, you may need to update the library path:
# Linux # macOS
Linking in C
# Linux
# Windows
π‘ Features
- Caching loaded locales in
temp/for fast startup - Fallback locale if a key is missing
- Extendable LC_* structure (add LC_MESSAGES, LC_MONETARY, etc.)
- Cross-platform (
.so/.dll) - Full C API compatible (
anlocales.h)