diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c7e631c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# Editorconfig to keep settings the same across devices and editors +# https://editorconfig.org/ + +root = true + +[*] +charset = utf-8 +indent_style = tab +insert_final_newline = true +tab_width = 4 +trim_trailing_whitespace = true + +[*.{html,md,py,rs}] +indent_size = 4 +indent_style = space + +[*.{yml,yaml}] +indent_style = space diff --git a/.github/.gitlint b/.github/.gitlint new file mode 100644 index 0000000..9755ab3 --- /dev/null +++ b/.github/.gitlint @@ -0,0 +1,2 @@ +[general] +ignore=B6 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..88d7df4 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# Global owner +* @ElBe-Plaq diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..defbeba --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,121 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement on +[our discord server](https://discord.gg/JVyyDukQqV). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html), +version 2.0, available at +[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html). + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are available at +[https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..6bfdfdc --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# How to contribute to this project + +Did you find a bug? You want to have a feature implemented? You made code better? +Please follow the instructions below on how to contribute to this project. + +## Notes + +Please do **not** report an issue of pull request if the issue is a security vulnerability. +There is a different way to report such issues. Issues or pull requests about a vulnerability will be removed. + +
+
+
+
+
+
+
+## About this project
+
+Localizer is a tool to translate text using json files.
+
+## Installing
+
+Run the following command to add the package to your dependencies:
+
+```bash
+
+$ cargo add localizer-rs
+...
+
+```
+
+### Git
+
+To clone the repository locally using git run `git clone https://github.com/ElBe-Development/localizer-rs.git`.
+
+## Usage
+
+To use localizer-rs, you need a directory (eg. `translations`) with your translations files (eg. `en.json`). You then need to follow these steps:
+
+1. Import the localizer-rs crate:
+
+ ```rust
+
+ use localizer_rs;
+
+ ```
+
+2. Create a new config object:
+
+ ```rust
+
+ let config = localizer_rs::Config::new("DIRECTORY NAME", "LANGUAGE NAME");
+
+ ```
+
+3. Translate your text:
+
+ ```rust
+
+ config.t("key", vec!["placeholder", "value"]);
+
+ ```
+
+## Example
+
+With the following `en.json` file.
+
+```json
+
+{
+ "error": "{{color.red}}{{bold}}Error:{{end}} Something went wrong: {{details}}."
+}
+
+```
+
+And the following rust code.
+
+```rust
+
+use localizer_rs;
+
+fn main() {
+ let config: localizer_rs::Config = localizer_rs::Config::new("translations", "en");
+
+ println!("{:}", config.t("error", vec![("details", "Path not found")]));
+}
+
+```
+
+You will get the following output:
+
+```bash
+
+Error: Something went wrong: Path not found.
+
+```
+
+Where `Error:` is red and bold.
+
+## Contact
+
+To contact us, get help or just chat with others, you can visit [our discord server](https://discord.gg/JVyyDukQqV).
diff --git a/.github/SECURITY.md b/.github/SECURITY.md
new file mode 100644
index 0000000..a6b3b74
--- /dev/null
+++ b/.github/SECURITY.md
@@ -0,0 +1,14 @@
+# Security Policy
+
+## Supported Versions
+
+| Version | Supported |
+| -------- | ------------------ |
+| `v1.0.0` | :white_check_mark: |
+
+## Reporting a Vulnerability
+
+To report a vulnerability, go to [our discord server](https://discord.gg/JVyyDukQqV), write an
+[E-Mail](mailto:elbe.dev.plaq@gmail.com) or report it via
+[GitHubs security reporting system](https://github.com/ElBe-Development/localizer-rs/security/advisories/new)
+(preferred).
diff --git a/.github/SUPPORT.md b/.github/SUPPORT.md
new file mode 100644
index 0000000..bd2a2fd
--- /dev/null
+++ b/.github/SUPPORT.md
@@ -0,0 +1,7 @@
+# Support
+
+You can get support on:
+
+- [our discord server](https://discord.gg/JVyyDukQqV)
+- [GitHub discussions](https://github.com/ElBe-Development/localizer-rs/discussions)
+- [GitHub issues](https://github.com/ElBe-Development/localizer-rs/issues)
diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml
new file mode 100644
index 0000000..fb03d3c
--- /dev/null
+++ b/.github/auto_assign.yml
@@ -0,0 +1,5 @@
+---
+addReviewers: false
+addAssignees: true
+assignees:
+ - ElBe-Plaq
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..ea3679d
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,33 @@
+# To get started with Dependabot version updates, you'll need to specify which
+# package ecosystems to update and where the package manifests are located.
+# Please see the documentation for all configuration options:
+# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
+---
+version: 2
+updates:
+ - package-ecosystem: "pip"
+ directory: "/"
+ schedule:
+ interval: "daily"
+ assignees:
+ - "ElBe-Plaq"
+ labels:
+ - "dependencies"
+
+ - package-ecosystem: "cargo"
+ directory: "/"
+ schedule:
+ interval: "daily"
+ assignees:
+ - "ElBe-Plaq"
+ labels:
+ - "dependencies"
+
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "daily"
+ assignees:
+ - "ElBe-Plaq"
+ labels:
+ - "dependencies"
diff --git a/.github/example.png b/.github/example.png
new file mode 100644
index 0000000..80da460
Binary files /dev/null and b/.github/example.png differ
diff --git a/.github/labeler.yml b/.github/labeler.yml
new file mode 100644
index 0000000..ac92c4e
--- /dev/null
+++ b/.github/labeler.yml
@@ -0,0 +1,5 @@
+---
+example:
+ - "examples/*"
+dependencies:
+ - "dev-requirements.txt"
diff --git a/.github/mergify.yml b/.github/mergify.yml
new file mode 100644
index 0000000..cb54a5e
--- /dev/null
+++ b/.github/mergify.yml
@@ -0,0 +1,128 @@
+---
+pull_request_rules:
+ - name: Merge trusted bot updates, no conflicts are present and approved
+ conditions:
+ - or:
+ - "label~=Approved"
+ - "-#approved-reviews-by=0"
+ - "-conflict"
+ - "-draft"
+ - "-locked"
+ - "#check-failure=0"
+ - "author~=.*bot.*"
+ actions:
+ comment:
+ message: |
+ # Merging pull request
+
+ Checks:
+ | Name | Status |
+ |------|--------|
+ {% for check in check_success %}| {{check}} | :white_check_mark: |
+ {% endfor %}
+ merge:
+ commit_message_template: |
+ {{title}}
+
+ {{title}} in #{{number}} by @{{author}}, contributing to {{milestone}}
+
+ Changed files:
+ {% for file in files %}- '{{file}}'
+ {% endfor %}
+
+ Approved by: @{{ approved_reviews_by | join(', @') }}
+
+
+ {% for commit in commits %}Co-authored-by: {{commit.author}} <{{commit.email_author}}>
+ {% endfor %}
+ method: merge
+ delete_head_branch:
+ - name: Merge if approved, no conflicts are present and it's not a WIP
+ conditions:
+ - or:
+ - "-#approved-reviews-by=0"
+ - "label~=Approved"
+ - "label~=Able to merge"
+ - "-conflict"
+ - "-draft"
+ - "-locked"
+ - "#check-failure=0"
+ actions:
+ comment:
+ message: |
+ # Merging pull request
+
+ Checks:
+ | Name | Status |
+ |------|--------|
+ {% for check in check_success %}| {{check}} | :white_check_mark: |
+ {% endfor %}
+ merge:
+ commit_message_template: |
+ {{title}}
+
+ {{title}} in #{{number}} by @{{author}}, contributing to {{milestone}}
+
+ Changed files:
+ {% for file in files %}- '{{file}}'
+ {% endfor %}
+
+ Approved by: @{{ approved_reviews_by | join(', @') }}
+
+
+ {% for commit in commits %}Co-authored-by: {{commit.author}} <{{commit.email_author}}>
+ {% endfor %}
+ method: merge
+ delete_head_branch:
+ - name: Add review requested label and request review from ElBe
+ conditions:
+ - or:
+ - "#approved-reviews-by=0"
+ - "-label~=Approved"
+ - "-title~=^[WIP].*"
+ - "-label~=Declined"
+ - "-label~=Review requested"
+ - "-draft"
+ - "-locked"
+ - "-conflict"
+ actions:
+ label:
+ add:
+ - Review requested
+ request_reviews:
+ users:
+ - ElBe-Plaq
+ - name: Warn on conflicts and add label
+ conditions:
+ - conflict
+ actions:
+ comment:
+ message: "@{{author}} this pull request has one or more conflicts."
+ label:
+ add:
+ - Invalid
+ remove:
+ - Review requested
+ - name: Remove invalid label if not needed
+ conditions:
+ - -conflict
+ actions:
+ label:
+ add:
+ - Review requested
+ remove:
+ - Invalid
+ - name: Warn on failed checks
+ conditions:
+ - "-#check-failure=0"
+ actions:
+ comment:
+ message: |
+ # Checks failed
+
+ Checks:
+ | Name | Status |
+ |------|--------|
+ {% for check in check_success %}| {{check}} | :white_check_mark: |
+ {% endfor %}{% for check in check_failure %}| {{check}} | :x: |
+ {% endfor %}
diff --git a/.github/stale.yml b/.github/stale.yml
new file mode 100644
index 0000000..a4d7996
--- /dev/null
+++ b/.github/stale.yml
@@ -0,0 +1,11 @@
+---
+daysUntilStale: 60
+daysUntilClose: 7
+exemptLabels:
+ - Security
+staleLabel: stale
+markComment: >
+ This issue has been automatically marked as stale because it has not had
+ recent activity. It will be closed if no further activity occurs. Thank you
+ for your contributions.
+closeComment: false
diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml
new file mode 100644
index 0000000..2962d4c
--- /dev/null
+++ b/.github/workflows/dependencies.yml
@@ -0,0 +1,46 @@
+---
+name: Dependencies
+permissions: read-all
+
+on:
+ push:
+ paths: ["dev-requirements.txt", "Cargo.toml"]
+
+ pull_request:
+ paths: ["dev-requirements.txt", "Cargo.toml"]
+
+jobs:
+ install-python-dependencies:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python-version: ["3.8"]
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v4
+ with:
+ python-version: ${{ matrix.python-version }}
+ - name: Install dependencies from txt files
+ run: |
+ python -m pip install --upgrade pip
+ pip install -r dev-requirements.txt
+ install-rust-dependencies:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install dependencies from Cargo.toml
+ run: cargo update
+ - name: Install dev-dependencies from Cargo.toml
+ run: cargo test --no-run
+ # ^ This is the only way to install dev-dependencies
+
+ dependency-review:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v3
+ if: ${{ github.event_name != 'push' }}
+ - name: Dependency Review
+ if: ${{ github.event_name != 'push' }}
+ uses: actions/dependency-review-action@v3
diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml
new file mode 100644
index 0000000..34a042d
--- /dev/null
+++ b/.github/workflows/label.yml
@@ -0,0 +1,25 @@
+# This workflow will triage pull requests and apply a label based on the
+# paths that are modified in the pull request.
+#
+# To use this workflow, you will need to set up a .github/labeler.yml
+# file with configuration. For more information, see:
+# https://github.com/actions/labeler
+
+---
+name: Labeler
+permissions:
+ pull-requests: write
+
+on: [pull_request_target]
+
+jobs:
+ label:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ pull-requests: write
+
+ steps:
+ - uses: actions/labeler@v4
+ with:
+ repo-token: "${{ secrets.GITHUB_TOKEN }}"
diff --git a/.github/workflows/megalinter.yml b/.github/workflows/megalinter.yml
new file mode 100644
index 0000000..7c38085
--- /dev/null
+++ b/.github/workflows/megalinter.yml
@@ -0,0 +1,38 @@
+---
+name: MegaLinter
+permissions: read-all
+
+on:
+ push:
+ pull_request:
+ branches: [main]
+
+env:
+ APPLY_FIXES: VALIDATE_ALL_CODEBASE
+ APPLY_FIXES_EVENT: all
+ APPLY_FIXES_MODE: commit
+
+concurrency:
+ group: ${{ github.ref }}-${{ github.workflow }}
+ cancel-in-progress: true
+
+jobs:
+ build:
+ name: MegaLinter
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ issues: write
+ pull-requests: write
+ steps:
+ - name: Checkout Code
+ uses: actions/checkout@v3
+ with:
+ token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
+ fetch-depth: 0
+ - name: MegaLinter
+ id: ml
+ uses: oxsecurity/megalinter@v7
+ env:
+ VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
new file mode 100644
index 0000000..2b42c87
--- /dev/null
+++ b/.github/workflows/rust.yml
@@ -0,0 +1,18 @@
+name: Rust
+permissions: read-all
+
+on:
+ [push, pull_request]
+
+env:
+ CARGO_TERM_COLOR: always
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Build
+ run: cargo build --verbose
+ - name: Run tests
+ run: cargo test --verbose
diff --git a/.mega-linter.yml b/.mega-linter.yml
new file mode 100644
index 0000000..b10c5b8
--- /dev/null
+++ b/.mega-linter.yml
@@ -0,0 +1,16 @@
+---
+DISABLE_ERRORS_LINTERS:
+ - SPELL_CSPELL
+ - REPOSITORY_DEVSKIM # cspell:disable-line
+ - MAKEFILE_CHECKMAKE # cspell:disable-line
+ - HTML_HTMLHINT # cspell:disable-line
+ - MARKDOWN_MARKDOWN_LINK_CHECK
+ - REPOSITORY_DUSTILOCK # cspell:disable-line
+ - JAVASCRIPT_STANDARD
+ - REPOSITORY_TRUFFLEHOG # cspell:disable-line
+ - SPELL_LYCHEE
+FILTER_REGEX_EXCLUDE: .*mypy.* # cspell:disable-line
+EDITORCONFIG_EDITORCONFIG_CHECKER_FILTER_REGEX_EXCLUDE: "Docs/acknowledgements.md|src/Installer/Linux/installer.bash"
+REPORT_OUTPUT_FOLDER: none
+SHOW_ELAPSED_TIME: true
+VALIDATE_ALL_CODEBASE: false
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..6c07b01
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,38 @@
+---
+repos:
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.4.0
+ hooks:
+ - id: check-added-large-files
+ - id: check-executables-have-shebangs
+ - id: check-json
+ - id: check-merge-conflict
+ - id: check-shebang-scripts-are-executable
+ - id: check-toml
+ - id: check-yaml
+ - id: pretty-format-json
+ args: [--autofix]
+ - id: requirements-txt-fixer
+ - id: trailing-whitespace
+ - repo: https://github.com/jorisroovers/gitlint
+ rev: v0.19.1
+ hooks:
+ - id: gitlint
+ args: [--config=.github\.gitlint, --msg-filename]
+ - repo: https://github.com/doublify/pre-commit-rust
+ rev: v1.0
+ hooks:
+ - id: fmt
+ - id: cargo-check
+ - repo: local
+ hooks:
+ - id: clippy
+ name: Run clippy linter
+ entry: cargo clippy -- -A non_snake_case
+ language: system
+ pass_filenames: false
+ci:
+ skip:
+ - fmt
+ - cargo-check
+ - clippy
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..e7c9c3a
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,23 @@
+[package]
+name = "localizer-rs"
+description = "Localizer helps localize (translate) your rust applications using json files."
+version = "1.0.0"
+authors = [
+ "ElBe-Plaq