Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
limuy2022 committed Jan 10, 2024
2 parents 3f81d62 + 86f1e04 commit b94d330
Show file tree
Hide file tree
Showing 45 changed files with 856 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Rust

on:
push:
branches: [ "master", "dev" ]
branches: [ "master" ]
pull_request:
branches: [ "master", "dev" ]

Expand Down
193 changes: 179 additions & 14 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
[package]
name = "rust"
name = "trc"
version = "0.1.0"
edition = "2021"
license = "GPL3"
authors = ["limuy"]
description = "a easy-learn programming language"
homepage = "https://github.com/limuy2022/trc"
repository = "https://github.com/limuy2022/trc"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.8.5"
clap = { version = "4.4.11", features = ["derive"] }
clap = { version = "4.4.12", features = ["derive"] }
gettext-rs = "0.7.0"
10 changes: 10 additions & 0 deletions rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ So this is just an experimental project and I will keep develop c++ version and
Like other common rust project.Just use ```cargo build```

Running tests is like other rust project,too.Just ```cargo test```

## How to use

[Trc user Guide](docs/usage.md)

## Provide translation for this project

The project use GNU Gettext lib tool to provide I18N(Internationalization) and L10N(localiation) support for the Trc.

If you want to help us to add more translation,please see [Trc translation Guide](docs/developer/translation.md)
10 changes: 10 additions & 0 deletions rust/docs/developer/reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# There are the references for the developers

1.the l10n and i18n settings for trc

[gettext official docs](https://www.gnu.org/software/gettext/manual/index.html)
[rust interface for gettest](//https://docs.rs/gettext-rs/latest/gettextrs/)

For Chinese develops:
[gettext manual1](https://www.cnblogs.com/chenxf0619/articles/4287608.html)
[gettext manual2](https://www.cnblogs.com/richardtien/articles/1884670.html)
17 changes: 17 additions & 0 deletions rust/docs/developer/translation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# How to add translation to the project

First, you can enter the language dir in the ```locales``` dir.If you want to add a new language.Please follow the following structure:

```locales/language_[region[.encoding]]/LC_MESSAGES```

For example,```locales/en_US.UTF-8/LC_MESSAGES```,```locales/en_US/LC_MESSAGES```,```locales/en/LC_MESSAGES```.

Then,create a translation file named ```trans.po``` in the dir.

Please refer to the [Translation Reference](./reference.md) to study how to add translation in the ```.po``` file.

After you finished the ```.po``` file.You can compile it to the binary file ```.mo``` that the Trc finally use.You can simply run the python script ```script/gen_locales.py``` to rebuilt all the language resources files.You can also run ```msgfmt -o trans.mo trans.po``` to jsut built this file.The former way is a little slower,but is more easy for beginners.

If there isn't ```msgfmt``` command in you Operating System.You can install it by the package manager or you can use ```msgfmt.py``` in python tools.It can work greatly,too.

Thank you for your contribution!
Loading

0 comments on commit b94d330

Please sign in to comment.