https://github.com/majigsaw77/kotoba
A lightweight Haxe library for XML-based language configuration and translation management.
https://github.com/majigsaw77/kotoba
haxe i18n language localization toolkit translation utility xml
Last synced: 4 months ago
JSON representation
A lightweight Haxe library for XML-based language configuration and translation management.
- Host: GitHub
- URL: https://github.com/majigsaw77/kotoba
- Owner: MAJigsaw77
- License: mit
- Created: 2025-08-05T17:25:01.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-05T17:29:48.000Z (11 months ago)
- Last Synced: 2025-08-05T19:25:11.282Z (11 months ago)
- Topics: haxe, i18n, language, localization, toolkit, translation, utility, xml
- Language: Haxe
- Homepage: https://lib.haxe.org/p/kobota
- Size: 52.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# kotoba
  
A lightweight Haxe library for XML-based language configuration and translation management.
### Installation
Using **Haxelib**:
```bash
haxelib install kotoba
```
Using **Git** (for latest changes):
```bash
haxelib git kotoba https://github.com/MAJigsaw77/kotoba.git
```
### How It Works
Kotoba loads translation files defined in a `config.xml`. You can organize your folders however you like — just make sure `Kotoba.initialize(path)` points to the directory containing `config.xml`, and the config lists your language folders and file IDs.
### Example File Structure
```
assets/
└── translations/
├── config.xml
├── en-US/
│ └── example_file.xml
└── ro-RO/
└── example_file.xml
```
### `config.xml`
```xml
```
### 🇺🇸 `en-US/example_file.xml`
```xml
```
### 🇷🇴 `ro-RO/example_file.xml`
```xml
```
### Usage
```haxe
import kotoba.Kotoba;
import kotoba.KotobaLoader;
import kotoba.KotobaReplacer;
import sys.FileSystem;
import sys.io.File;
class Main
{
public static function main():Void
{
// Hook Kotoba into your file loading logic
KotobaLoader.exists = FileSystem.exists;
KotobaLoader.getContent = File.getContent;
// Choose a language
Kotoba.language = 'ro-RO';
// Load translations from folder
Kotoba.initialize('assets/translations');
// Fetch and format a translated string
final raw:String = Kotoba.getString('example_file', 'example_id', 'Fallback text');
final result:String = KotobaReplacer.replace(raw, { money: 20 });
trace(result); // → Ai câștigat 20 lei!
}
}
```
---
### License
**kotoba** is released under the MIT License. See [LICENSE](./LICENSE) for details.