localize
Compile time localization for applications and libraries
Summary
| Latest Version | 0.3.5 |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-09-02 07:20 |
Tags
Authors
- levovix0
Installation
nimble install localize
choosenim install localize
git clone https://github.com/levovix0/localize
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| localize | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Dependencies
| Package | Version | Optional |
|---|---|---|
| nim >= | 1.6.12 | No |
Source
| Repository | https://github.com/levovix0/localize |
|---|---|
| Homepage | https://github.com/levovix0/localize |
| Registry Source | nimble_official |
README
Localize

Localize your applications at compile-time
app.nim
import localize
requireLocalesToBeTranslated ("ru", "")
echo tr"Hello, world" # "Hello, world"
globalLocale = locale "ru"
echo tr"Hello, world" # "Привет, мир"
when isMainModule:
updateTranslations() # traslations is readed and updated when compiling
translations/ru.json
{
"app.nim": {
"Hello, world": {
"": "Привет, мир"
}
}
}
- Static translations are generated for each nimble packege that uses localize, in package root directory
specifing context
"it is working!".tr # same as "" context
"it is working!".tr("") # "оно работает!"
"it is working!".tr("code") # "он работает!"
{
"app.nim": {
"it is working!": {
"": "оно работает!",
"code": "он работает!"
}
}
}
formating
tr is auto-calling fmt
let name = stdin.readline
echo tr"Hi, {name}"
{
"app.nim": {
"Hi, {name}": {
"": "Привет, {name}",
}
}
}
detecting system language
globalLocale[0] = systemLocale()
- system locale values are based on linux's LANG env variable
dynamic translations
import json
globalLocale = (
("zh", ""),
parseLocaleTable %*{
"mypackage": {
"src/myapp.nim": {
"Hello, world": {
"": "你好,世界",
},
},
},
}
)
- Dynamic translations files are diffirent from static translations files: they contain table for modules
- For now, dynamic translations are not formated
known issues
- for now, dynamicly loaded translations cannot be formated at all