Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21f8c781ee | ||
|
|
3f69ad6aaf | ||
|
|
e011a01b31 | ||
|
|
70f5e4b28b | ||
|
|
5f1952f362 | ||
|
|
97b67a7713 | ||
|
|
31a390f25f | ||
|
|
25ecd37d7d | ||
|
|
195b9edc34 | ||
|
|
f50157eae0 | ||
|
|
4e8f910351 |
+4
-4
@@ -38,7 +38,7 @@ To use localizer-rs, you need a directory (eg. `translations`) with your transla
|
|||||||
|
|
||||||
1. Import the localizer-rs crate:
|
1. Import the localizer-rs crate:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
|
|
||||||
use localizer_rs;
|
use localizer_rs;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ To use localizer-rs, you need a directory (eg. `translations`) with your transla
|
|||||||
|
|
||||||
2. Create a new config object:
|
2. Create a new config object:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
|
|
||||||
let config = localizer_rs::Config::new("DIRECTORY NAME", "LANGUAGE NAME");
|
let config = localizer_rs::Config::new("DIRECTORY NAME", "LANGUAGE NAME");
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ To use localizer-rs, you need a directory (eg. `translations`) with your transla
|
|||||||
|
|
||||||
3. Translate your text:
|
3. Translate your text:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
|
|
||||||
config.t("key", vec!["placeholder", "value"]);
|
config.t("key", vec!["placeholder", "value"]);
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ With the following `en.json` file.
|
|||||||
|
|
||||||
And the following rust code.
|
And the following rust code.
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
|
|
||||||
use localizer_rs;
|
use localizer_rs;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
| -------- | ------------------ |
|
| -------- | ------------------ |
|
||||||
| `v1.0.0` | :white_check_mark: |
|
| `v1.0.0` | :white_check_mark: |
|
||||||
| `v1.1.0` | :white_check_mark: |
|
| `v1.1.0` | :white_check_mark: |
|
||||||
|
| `v1.1.1` | :white_check_mark: |
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
name: Codecov
|
||||||
|
permissions: read-all
|
||||||
|
|
||||||
|
on:
|
||||||
|
[push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
- name: Upload coverage reports to Codecov
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
env:
|
||||||
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.8"]
|
python-version: ["3.8"]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
install-rust-dependencies:
|
install-rust-dependencies:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Install dependencies from Cargo.toml
|
- name: Install dependencies from Cargo.toml
|
||||||
run: cargo update
|
run: cargo update
|
||||||
- name: Install dev-dependencies from Cargo.toml
|
- name: Install dev-dependencies from Cargo.toml
|
||||||
@@ -39,7 +39,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
if: ${{ github.event_name != 'push' }}
|
if: ${{ github.event_name != 'push' }}
|
||||||
- name: Dependency Review
|
- name: Dependency Review
|
||||||
if: ${{ github.event_name != 'push' }}
|
if: ${{ github.event_name != 'push' }}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cargo build --verbose
|
run: cargo build --verbose
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "localizer-rs"
|
name = "localizer-rs"
|
||||||
description = "Localizer helps localize (translate) your rust applications using json files."
|
description = "Localizer helps localize (translate) your rust applications using json files."
|
||||||
version = "1.1.0"
|
version = "1.1.1"
|
||||||
authors = [
|
authors = [
|
||||||
"ElBe-Plaq <elbe.dev.plaq@gmail.com>"
|
"ElBe-Plaq <elbe.dev.plaq@gmail.com>"
|
||||||
]
|
]
|
||||||
@@ -10,7 +10,7 @@ rust-version = "1.69"
|
|||||||
documentation = "https://docs.rs/localizer_rs/"
|
documentation = "https://docs.rs/localizer_rs/"
|
||||||
readme = ".github/README.md"
|
readme = ".github/README.md"
|
||||||
repository = "https://github.com/ElBe-Development/localizer-rs/"
|
repository = "https://github.com/ElBe-Development/localizer-rs/"
|
||||||
license-file = "LICENSE.txt"
|
license = "MIT"
|
||||||
keywords = ["i18n", "L10n", "json", "local", "translation"]
|
keywords = ["i18n", "L10n", "json", "local", "translation"]
|
||||||
categories = [
|
categories = [
|
||||||
"internationalization",
|
"internationalization",
|
||||||
@@ -20,4 +20,4 @@ publish = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = "1.0.188"
|
serde = "1.0.188"
|
||||||
serde_json = "1.0.106"
|
serde_json = "1.0.107"
|
||||||
|
|||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
coverage:
|
||||||
|
status:
|
||||||
|
project:
|
||||||
|
default:
|
||||||
|
target: 50%
|
||||||
|
threshold: 1%
|
||||||
|
|
||||||
|
comment:
|
||||||
|
require_changes: true
|
||||||
|
require_ci_to_pass: false
|
||||||
@@ -1 +1 @@
|
|||||||
pre-commit==3.3.2; python_version>='3.8'
|
pre-commit==3.4.0; python_version>='3.8'
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ build *ARGUMENTS:
|
|||||||
|
|
||||||
# Removes temporary files
|
# Removes temporary files
|
||||||
clean:
|
clean:
|
||||||
rm -rf target
|
cargo clean
|
||||||
rm -rf Tools/__pycache__
|
|
||||||
|
|
||||||
# Lints the rust source files
|
# Lints the rust source files
|
||||||
lint *ARGUMENTS:
|
lint *ARGUMENTS:
|
||||||
|
|||||||
+4
-1
@@ -1,5 +1,5 @@
|
|||||||
// localizer-rs errors
|
// localizer-rs errors
|
||||||
// Version: 1.1.0
|
// Version: 1.1.1
|
||||||
|
|
||||||
// Copyright (c) 2023-present ElBe Development.
|
// Copyright (c) 2023-present ElBe Development.
|
||||||
|
|
||||||
@@ -58,8 +58,11 @@ use std::fmt;
|
|||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct Error {
|
pub struct Error {
|
||||||
|
/// The errors name.
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
/// The error description.
|
||||||
pub description: String,
|
pub description: String,
|
||||||
|
/// The errors exit code.
|
||||||
pub exit_code: i32,
|
pub exit_code: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-13
@@ -1,6 +1,6 @@
|
|||||||
#![doc = ".github/README.md"]
|
#[doc = include_str!("../.github/README.md")]
|
||||||
// localizer-rs
|
// localizer-rs
|
||||||
// Version: 1.1.0
|
// Version: 1.1.1
|
||||||
|
|
||||||
// Copyright (c) 2023-present ElBe Development.
|
// Copyright (c) 2023-present ElBe Development.
|
||||||
|
|
||||||
@@ -37,8 +37,6 @@ use std::fs::File;
|
|||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use errors as error_lib;
|
|
||||||
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
|
|
||||||
@@ -52,7 +50,8 @@ use serde_json;
|
|||||||
///
|
///
|
||||||
/// # Parameters
|
/// # Parameters
|
||||||
///
|
///
|
||||||
/// - `path`: The directory containing the translation files. The directory is relative to the path the executable was executed from.
|
/// - `path`: The directory containing the translation files.
|
||||||
|
/// The directory is relative to the path the executable was executed from.
|
||||||
/// - `language`: The language to translate to.
|
/// - `language`: The language to translate to.
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
@@ -70,7 +69,10 @@ use serde_json;
|
|||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
/// The directory containing the translation files. The directory is relative to the path the
|
||||||
|
/// executable was executed from.
|
||||||
pub path: String,
|
pub path: String,
|
||||||
|
/// The language to translate to.
|
||||||
pub language: String,
|
pub language: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +86,8 @@ impl Config {
|
|||||||
///
|
///
|
||||||
/// # Parameters
|
/// # Parameters
|
||||||
///
|
///
|
||||||
/// - `path`: The directory containing the translation files. The directory is relative to the path the executable was executed from.
|
/// - `path`: The directory containing the translation files.
|
||||||
|
/// The directory is relative to the path the executable was executed from.
|
||||||
/// - `language`: The language to translate to.
|
/// - `language`: The language to translate to.
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
@@ -122,7 +125,8 @@ impl Config {
|
|||||||
/// # Parameters
|
/// # Parameters
|
||||||
///
|
///
|
||||||
/// - `self`: The config object. This must be mutable.
|
/// - `self`: The config object. This must be mutable.
|
||||||
/// - `str_path`: The directory containing the translation files. The directory is relative to the path the executable was executed from.
|
/// - `str_path`: The directory containing the translation files.
|
||||||
|
/// The directory is relative to the path the executable was executed from.
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
///
|
///
|
||||||
@@ -149,14 +153,14 @@ impl Config {
|
|||||||
match path.try_exists() {
|
match path.try_exists() {
|
||||||
Ok(value) => {
|
Ok(value) => {
|
||||||
if !value {
|
if !value {
|
||||||
let error: error_lib::Error =
|
let error: errors::Error =
|
||||||
error_lib::Error::new("OS Error", "Translation path was not found", 1);
|
errors::Error::new("OS Error", "Translation path was not found", 1);
|
||||||
error.raise(format!("Path: {:?}", str_path).as_str());
|
error.raise(format!("Path: {:?}", str_path).as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_error) => {
|
Err(_error) => {
|
||||||
let error: error_lib::Error =
|
let error: errors::Error =
|
||||||
error_lib::Error::new("OS Error", "Could not open path", 2);
|
errors::Error::new("OS Error", "Could not open path", 2);
|
||||||
error.raise(format!("Path: {:?}\nDetails: {}", str_path, _error).as_str());
|
error.raise(format!("Path: {:?}\nDetails: {}", str_path, _error).as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,8 +168,8 @@ impl Config {
|
|||||||
self.path = String::from(match path.to_owned().to_str() {
|
self.path = String::from(match path.to_owned().to_str() {
|
||||||
Some(value) => value,
|
Some(value) => value,
|
||||||
None => {
|
None => {
|
||||||
let error: error_lib::Error =
|
let error: errors::Error =
|
||||||
error_lib::Error::new("OS Error", "Path does not seem to be valid", 3);
|
errors::Error::new("OS Error", "Path does not seem to be valid", 3);
|
||||||
error.raise(format!("Path: {:?}", str_path).as_str());
|
error.raise(format!("Path: {:?}", str_path).as_str());
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// localizer-rs error tests
|
// localizer-rs error tests
|
||||||
// Version: 1.1.0
|
// Version: 1.1.1
|
||||||
|
|
||||||
// Copyright (c) 2023-present ElBe Development.
|
// Copyright (c) 2023-present ElBe Development.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// localizer-rs tests
|
// localizer-rs tests
|
||||||
// Version: 1.1.0
|
// Version: 1.1.1
|
||||||
|
|
||||||
// Copyright (c) 2023-present ElBe Development.
|
// Copyright (c) 2023-present ElBe Development.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user