Unverified Commit 947d208a authored by Katharina Fey's avatar Katharina Fey 🏴
Browse files

Initial commit

parents
/target
Cargo.lock
[package]
name = "traduki"
version = "0.1.0"
authors = ["Katharina Fey <kookie@spacekookie.de>"]
edition = "2018"
[dependencies]
# taduki
An asset translation toolkit for Rust.
## The problem
We've all built applications that hade user-facing text. Whether they
are error messages, help messages, the general UI text, etc; almost
all application text can and should be translated into the user's
preferred language to make using software as accessible and easy as
possible.
However, managing translations is hard, especially when it cames to
accessing strings in different parts of an application, or even in
multiple crates in the same workspace.
Additionally applications aren't the only things that can be
translated: manual pages, help texts, even static websites can all be
translated and generated with language specific texts.
## Overview
`traduki` adds the "lang-assets" directory, in which users can create
a losely managed structure of texts and asset files for translations.
Currently these have to be edited by hand, but it's plausible to have
a web-ui to handle translations, that can make PRs/ commits
automatically to make it easier for people to contribute.
### Asset directory structure
A popular approach to handling translation assets is to have a
top-level language section, followed by a custom tree of objects. The
problem of this approach is that it makes it incredibly easy for
different language trees to drift out of sync with each other.
Instead, `traduki` uses the "wikipedia model": at the top level is a
set of categories, filled with sub-categories and "pages" (assets).
Each asset is a folder which contains language specific files.
This way it's much easier to compare the state of translations for
each language at a glance and discourages pages or sections to only
exist in one language.
### Format
Following is a very simple directory layout of how to use `taduki`.
For more complex examples, check the `examples` directory.
```
assets/
├── clap
│   ├── create
│   │   ├── en_GB.yml
│   │   ├── eo.yml
│   │   └── fr_FR.yml
│   ├── default
│   │   ├── en_GB.yml
│   │   ├── eo.yml
│   │   └── fr_FR.yml
│   └── destroy
│   ├── en_GB.yml
│   └── eo.yml
└── manual
├── en_GB.yml
├── eo.yml
└── fr_FR.yml
```
In this example the `clap` directory contains data regarding the CLI,
grouped by subcommand (with `default/` contains general arguments, the
application name, version, disclaimer, etc.
The manual section doesn't have sub-sections and is a leaf node (with
three languages).
In your `build.rs` you should add this line
```
fn main() {
traduki::bootstrap("assets/").unwrap();
}
```
In your Rust program (after initialising `taduki`, you will be able to
get assets with `crate::taduki::clap::create::my_key_here`).
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment