pax_global_header00006660000000000000000000000064151736343230014521gustar00rootroot0000000000000052 comment=f2b2a6170c6adeb7c5148b588fe6d739fd402bf9 webhippie-po_to_json-f2b2a61/000077500000000000000000000000001517363432300162515ustar00rootroot00000000000000webhippie-po_to_json-f2b2a61/.codacy.yml000066400000000000000000000000511517363432300203100ustar00rootroot00000000000000--- exclude_paths: - CHANGELOG.md ... webhippie-po_to_json-f2b2a61/.github/000077500000000000000000000000001517363432300176115ustar00rootroot00000000000000webhippie-po_to_json-f2b2a61/.github/RELEASE000066400000000000000000000000351517363432300206120ustar00rootroot00000000000000Mon Apr 20 10:03:14 UTC 2026 webhippie-po_to_json-f2b2a61/.github/renovate.json000066400000000000000000000005701517363432300223310ustar00rootroot00000000000000{ "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ "github>webhippie/.github//renovate/preset" ], "packageRules": [ { "matchDatasources": [ "rubygems" ], "matchPackageNames": [ "listen" ], "enabled": false } ] } webhippie-po_to_json-f2b2a61/.github/semantic.yml000066400000000000000000000003641517363432300221420ustar00rootroot00000000000000--- commitsOnly: true anyCommit: true allowMergeCommits: true allowRevertCommits: true types: - feat - fix - docs - style - refactor - perf - test - build - ci - chore - revert - major - minor - patch - deps ... webhippie-po_to_json-f2b2a61/.github/settings.yml000066400000000000000000000103461517363432300222000ustar00rootroot00000000000000--- repository: name: po_to_json description: Ruby library for converting gettext PO files to JSON homepage: https://github.com/webhippie/po_to_json topics: ruby, rubygem, gettext, i18n, json private: false has_issues: true has_wiki: false has_downloads: false default_branch: master allow_merge_commit: false allow_squash_merge: true allow_rebase_merge: true allow_update_branch: true allow_auto_merge: true delete_branch_on_merge: true enable_automated_security_fixes: true enable_vulnerability_alerts: true rulesets: - name: prevent destruction target: branch enforcement: active conditions: ref_name: include: - "~DEFAULT_BRANCH" exclude: [] rules: - type: required_linear_history - type: deletion - type: non_fast_forward - name: check verification target: branch enforcement: active conditions: ref_name: include: - "~DEFAULT_BRANCH" exclude: [] rules: - type: required_status_checks parameters: strict_required_status_checks_policy: true required_status_checks: - context: rubocop integration_id: 15368 bypass_actors: - actor_id: 1 actor_type: OrganizationAdmin bypass_mode: always - actor_id: 951695 # app actor_type: Integration bypass_mode: always - actor_id: 6359533 # bots actor_type: Team bypass_mode: always - name: require reviewing target: branch enforcement: active conditions: ref_name: include: - "~DEFAULT_BRANCH" exclude: [] rules: - type: pull_request parameters: allowed_merge_methods: - squash - rebase dismiss_stale_reviews_on_push: false require_code_owner_review: false require_last_push_approval: false required_approving_review_count: 0 required_review_thread_resolution: false bypass_actors: - actor_id: 1 actor_type: OrganizationAdmin bypass_mode: always - actor_id: 951695 # app actor_type: Integration bypass_mode: always - actor_id: 6359533 # bots actor_type: Team bypass_mode: always teams: - name: admins permission: admin - name: bots permission: admin - name: members permission: maintain labels: - name: bug color: fc2929 description: Something isn't working - name: duplicate color: cccccc description: This issue or pull request already exists - name: enhancement color: 84b6eb description: New feature or request - name: good first issue color: 7057ff description: Good for newcomers - name: help wanted color: 159818 description: Extra attention is needed - name: invalid color: e6e6e6 description: This doesn't seem right - name: question color: cc317c description: Further information is requested - name: renovate color: 1d76db description: Automated action from Renovate - name: wontfix color: 5319e7 description: This will not be worked on - name: hacktoberfest color: d4c5f9 description: Contribution at Hacktoberfest appreciated - name: ready color: ededed description: This is ready to be worked on - name: in progress color: ededed description: This is currently worked on - name: infra color: 006b75 description: Related to the infrastructure - name: lint color: fbca04 description: Related to linting tools - name: poc color: c2e0c6 description: Proof of concept for new feature - name: rebase color: ffa8a5 description: Branch requires a rebase - name: third-party color: e99695 description: Depends on third-party tool or library - name: translation color: b60205 description: Change or issue related to translations - name: ci color: b60105 description: Related to Continous Integration - name: docs color: b60305 description: Related to documentation - name: outdated color: cccccc description: This is out of scope and outdated - name: tools color: 1d76db description: Tools updates used for CI and other tasks ... webhippie-po_to_json-f2b2a61/.github/workflows/000077500000000000000000000000001517363432300216465ustar00rootroot00000000000000webhippie-po_to_json-f2b2a61/.github/workflows/automerge.yml000066400000000000000000000022071517363432300243620ustar00rootroot00000000000000--- # yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json name: automerge "on": workflow_dispatch: pull_request: branches: - master permissions: contents: write pull-requests: write jobs: dependabot: runs-on: ubuntu-latest if: github.actor == 'dependabot[bot]' steps: - name: Generate token id: token uses: actions/create-github-app-token@v3 with: app-id: ${{ secrets.TOKEN_EXCHANGE_APP }} private-key: ${{ secrets.TOKEN_EXCHANGE_KEY }} permission-contents: write permission-pull-requests: write permission-issues: write - name: Fetch metadata uses: dependabot/fetch-metadata@v3 with: github-token: ${{ secrets.GITHUB_TOKEN }} - name: Approve request run: gh pr review --approve "${{github.event.pull_request.html_url}}" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Enable automerge run: gh pr merge --rebase --auto "${{github.event.pull_request.html_url}}" env: GH_TOKEN: ${{ steps.token.outputs.token }} ... webhippie-po_to_json-f2b2a61/.github/workflows/flake.yml000066400000000000000000000021661517363432300234600ustar00rootroot00000000000000--- # yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json name: flake "on": workflow_dispatch: schedule: - cron: "0 8 * * 1" permissions: contents: write jobs: flake: runs-on: ubuntu-latest steps: - name: Generate token id: token uses: actions/create-github-app-token@v3 with: app-id: ${{ secrets.TOKEN_EXCHANGE_APP }} private-key: ${{ secrets.TOKEN_EXCHANGE_KEY }} permission-contents: write - name: Checkout source uses: actions/checkout@v6 with: token: ${{ steps.token.outputs.token }} - name: Install nix uses: cachix/install-nix-action@v31 - name: Update flake run: nix flake update - name: Source rebase run: git pull --autostash --rebase - name: Commit changes uses: EndBug/add-and-commit@v10 with: author_name: GitHub Actions author_email: github@webhippie.de add: flake.lock message: "chore(flake): updated lockfile [skip ci]" push: true commit: --signoff ... webhippie-po_to_json-f2b2a61/.github/workflows/release.yml000066400000000000000000000040231517363432300240100ustar00rootroot00000000000000--- # yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json name: release "on": workflow_dispatch: schedule: - cron: "0 8 * * 1" permissions: contents: read id-token: write jobs: release: runs-on: ubuntu-latest steps: - name: Setup nodejs uses: actions/setup-node@v6 with: node-version: lts/* - name: Generate token id: token uses: actions/create-github-app-token@v3 with: app-id: ${{ secrets.TOKEN_EXCHANGE_APP }} private-key: ${{ secrets.TOKEN_EXCHANGE_KEY }} permission-contents: write permission-pull-requests: write permission-issues: write - name: Checkout source uses: actions/checkout@v6 with: token: ${{ steps.token.outputs.token }} - name: Setup nodejs uses: actions/setup-node@v6 with: node-version: 24.x - name: Setup ruby uses: ruby/setup-ruby@v1 with: bundler-cache: true - name: Install releaser run: | npm install -g \ semantic-release@25.0.2 \ @semantic-release/changelog \ @semantic-release/git \ @semantic-release/github \ @webhippie/semantic-release-rubygem \ semantic-release-replace-plugin \ conventional-changelog-conventionalcommits - name: Run releaser env: GITHUB_TOKEN: ${{ secrets.BOT_ACCESS_TOKEN }} GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} run: semantic-release - name: Write buildtime run: date >| .github/RELEASE - name: Update repo run: git pull --rebase --autostash - name: Commit changes uses: EndBug/add-and-commit@v10 with: author_name: GitHub Actions author_email: github@webhippie.de add: .github/RELEASE message: "docs: automated release update [skip ci]" push: true commit: --signoff ... webhippie-po_to_json-f2b2a61/.github/workflows/testing.yml000066400000000000000000000026231517363432300240510ustar00rootroot00000000000000--- # yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json name: testing "on": workflow_dispatch: pull_request: push: branches: - master permissions: contents: read jobs: rubocop: runs-on: ubuntu-latest steps: - name: Checkout source uses: actions/checkout@v6 - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: 4.0.3 bundler-cache: true - name: Run rubocop run: bundle exec rubocop spec: runs-on: ubuntu-latest needs: rubocop strategy: fail-fast: false matrix: ruby: - "2.7" - "3.0" - "3.1" - "3.2" - "3.3" json: - "1.6" - "1.7" - "1.8" - "2.0" - "2.1" - "2.2" - "2.3" - "2.4" - "2.5" - "2.6" - "2.7" - "2.8" - "2.9" - "2.10" - "2.11" - "2.12" - "2.13" steps: - name: Checkout source uses: actions/checkout@v6 - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true rubygems: latest env: JSON_VERSION: ${{ matrix.json }} - name: Run rspec run: bundle exec rspec ... webhippie-po_to_json-f2b2a61/.gitignore000066400000000000000000000001761517363432300202450ustar00rootroot00000000000000.direnv/ .devenv/ .yardoc .bundle .vagrant coverage/ pkg/ doc/ vendor/ Gemfile.lock Gemfile.local .pre-commit-config.yaml webhippie-po_to_json-f2b2a61/.releaserc000066400000000000000000000124421517363432300202220ustar00rootroot00000000000000{ "branches": [ "master" ], "plugins": [ [ "@semantic-release/commit-analyzer", { "preset": "conventionalcommits", "releaseRules": [ { "type": "major", "release": "major" }, { "type": "deps", "scope": "major", "release": "major" }, { "type": "minor", "release": "minor" }, { "type": "deps", "scope": "minor", "release": "minor" }, { "type": "patch", "release": "patch" }, { "type": "deps", "scope": "patch", "release": "patch" }, { "type": "refactor", "release": "minor" }, { "scope": "docs", "release": false } ] } ], [ "@semantic-release/release-notes-generator", { "preset": "conventionalcommits", "presetConfig": { "types": [ { "type": "major", "section": "Features" }, { "type": "minor", "section": "Features" }, { "type": "patch", "section": "Bugfixes" }, { "type": "feat", "section": "Features" }, { "type": "fix", "section": "Bugfixes" }, { "type": "deps", "section": "Dependencies" }, { "type": "chore", "section": "Miscellaneous", "hidden": false }, { "type": "docs", "hidden": true }, { "type": "refactor", "hidden": true } ] } } ], [ "@semantic-release/changelog", { "changelogTitle": "# Changelog" } ], [ "semantic-release-replace-plugin", { "replacements": [ { "files": [ "README.md" ], "from": "gem 'po_to_json', '~> .*'", "to": "gem 'po_to_json', '~> ${nextRelease.version}'", "results": [ { "file": "README.md", "hasChanged": true, "numMatches": 1, "numReplacements": 1 } ], "countMatches": true }, { "files": [ "README.md" ], "from": "spec.add_dependency 'po_to_json', '~> .*'", "to": "spec.add_dependency 'po_to_json', '~> ${nextRelease.version}'", "results": [ { "file": "README.md", "hasChanged": true, "numMatches": 1, "numReplacements": 1 } ], "countMatches": true } ] } ], [ "@webhippie/semantic-release-rubygem", { "updateGemfileLock": false, "gemPublish": true, "versionGlob": "lib/*/version.rb" } ], [ "@semantic-release/git", { "message": "chore: release ${nextRelease.version}", "assets": [ "CHANGELOG.md", "README.md", "lib/po_to_json/version.rb" ] } ], [ "@semantic-release/github", { "assets": [ "pkg/*.gem" ] } ] ] } webhippie-po_to_json-f2b2a61/.rspec000066400000000000000000000000401517363432300173600ustar00rootroot00000000000000--colour --format documentation webhippie-po_to_json-f2b2a61/.rubocop.yml000066400000000000000000000020621517363432300205230ustar00rootroot00000000000000--- AllCops: NewCops: enable SuggestExtensions: false TargetRubyVersion: 2.6 Gemspec/RequiredRubyVersion: Enabled: false Naming/HeredocDelimiterNaming: Enabled: false Layout/ElseAlignment: Enabled: false Style/StringLiterals: EnforcedStyle: double_quotes Style/StringLiteralsInInterpolation: EnforcedStyle: double_quotes Style/Documentation: Enabled: false Style/ModuleFunction: Enabled: false Style/WordArray: Enabled: false Style/PerlBackrefs: Enabled: false Style/Next: Enabled: false Style/RegexpLiteral: Enabled: false Style/SymbolArray: EnforcedStyle: brackets Metrics/MethodLength: CountComments: false Max: 30 Metrics/ClassLength: Max: 300 Metrics/AbcSize: Max: 25 Metrics/PerceivedComplexity: Max: 10 Metrics/BlockLength: Max: 35 Exclude: - "**/*_spec.rb" Layout/LineLength: Exclude: - "**/*_spec.rb" Naming/VariableNumber: EnforcedStyle: snake_case Style/FormatStringToken: EnforcedStyle: template Naming/PredicateMethod: Enabled: false Style/RedundantFreeze: Enabled: false ... webhippie-po_to_json-f2b2a61/.ruby-version000066400000000000000000000000061517363432300207120ustar00rootroot000000000000004.0.3 webhippie-po_to_json-f2b2a61/CHANGELOG.md000066400000000000000000000144611517363432300200700ustar00rootroot00000000000000# Changelog ## [3.0.3](https://github.com/webhippie/po_to_json/compare/v3.0.2...v3.0.3) (2026-04-27) ### Dependencies * **patch:** update dependency ruby to v4.0.3 ([#69](https://github.com/webhippie/po_to_json/issues/69)) ([a5f4081](https://github.com/webhippie/po_to_json/commit/a5f40816655182aa55acfbd24d640a9d565a2a9d)) ### Miscellaneous * **flake:** updated lockfile [skip ci] ([f9a140f](https://github.com/webhippie/po_to_json/commit/f9a140fd816b4af7383797194d11bb2dc16dd8d2)) * **flake:** updated lockfile [skip ci] ([46d1f79](https://github.com/webhippie/po_to_json/commit/46d1f794b31219d96f0a622093a2eef8d2c428a8)) * **flake:** updated lockfile [skip ci] ([86f689b](https://github.com/webhippie/po_to_json/commit/86f689b6d2ba61e5a3e550ec48a32a111e0f3aed)) * **flake:** updated lockfile [skip ci] ([0316c7e](https://github.com/webhippie/po_to_json/commit/0316c7ebece96c163a94341382fd6dcea8c60f66)) * **flake:** updated lockfile [skip ci] ([3423ad3](https://github.com/webhippie/po_to_json/commit/3423ad3a4e6156aa26fdbd38626f9ddb906078e4)) ## [3.0.2](https://github.com/webhippie/po_to_json/compare/v3.0.1...v3.0.2) (2026-03-23) ### Dependencies * **patch:** update dependency ruby to v4.0.2 ([#65](https://github.com/webhippie/po_to_json/issues/65)) ([b06204a](https://github.com/webhippie/po_to_json/commit/b06204a9498d0dbf30bfb50ba6479157a861639a)) ### Miscellaneous * **flake:** updated lockfile [skip ci] ([68a1a1f](https://github.com/webhippie/po_to_json/commit/68a1a1f85dd684763eae6d5aa316a14df1479a94)) * **flake:** updated lockfile [skip ci] ([adf093a](https://github.com/webhippie/po_to_json/commit/adf093a9682d835384ee8c7f20a26936afd58067)) * **flake:** updated lockfile [skip ci] ([d0e126e](https://github.com/webhippie/po_to_json/commit/d0e126e2003dba10efda7263e11d758e879e529d)) * **flake:** updated lockfile [skip ci] ([521ed77](https://github.com/webhippie/po_to_json/commit/521ed77ecbaf072c4f4362180286561d77214e04)) * **flake:** updated lockfile [skip ci] ([8fb9515](https://github.com/webhippie/po_to_json/commit/8fb95150b11b566db5b7f9b038b676115e252b2c)) * **flake:** updated lockfile [skip ci] ([37869ae](https://github.com/webhippie/po_to_json/commit/37869aeed799850c6dda684535f4e9fa8535938d)) * **flake:** updated lockfile [skip ci] ([1f8de34](https://github.com/webhippie/po_to_json/commit/1f8de341099681b85d5c9a1f59768ff1dee71391)) * **flake:** updated lockfile [skip ci] ([b588fb5](https://github.com/webhippie/po_to_json/commit/b588fb5dbad5f5d3ca0f68cb30465d3e2a85f0d8)) * **flake:** updated lockfile [skip ci] ([96a77c2](https://github.com/webhippie/po_to_json/commit/96a77c2d79da73902cbe1188cd75dfd1b59c8485)) ## [3.0.1](https://github.com/webhippie/po_to_json/compare/v3.0.0...v3.0.1) (2026-01-19) ### Dependencies * **patch:** update dependency ruby to v4.0.1 ([#62](https://github.com/webhippie/po_to_json/issues/62)) ([b4416c5](https://github.com/webhippie/po_to_json/commit/b4416c54d045c5ab266b678cadc51612cdd140b2)) ### Miscellaneous * **flake:** updated lockfile [skip ci] ([be7c782](https://github.com/webhippie/po_to_json/commit/be7c78296384f9681d855e55364dedf86cdb0739)) * **flake:** updated lockfile [skip ci] ([b9139d7](https://github.com/webhippie/po_to_json/commit/b9139d756cd3e770d1c6ab3799da5fdf4e368da9)) * **flake:** updated lockfile [skip ci] ([c875aa6](https://github.com/webhippie/po_to_json/commit/c875aa67babac21fc0d53920ec57e42f152e0fdf)) ## [3.0.0](https://github.com/webhippie/po_to_json/compare/v2.2.1...v3.0.0) (2025-12-29) ### Features * **major:** update dependency ruby to v4 ([#59](https://github.com/webhippie/po_to_json/issues/59)) ([88b615e](https://github.com/webhippie/po_to_json/commit/88b615e8957433c3f10f998efe303207ae241ae0)) ## [2.2.1](https://github.com/webhippie/po_to_json/compare/v2.2.0...v2.2.1) (2025-12-22) ### Bugfixes * **patch:** update dependency ruby to v3.4.8 ([#57](https://github.com/webhippie/po_to_json/issues/57)) ([846d0e1](https://github.com/webhippie/po_to_json/commit/846d0e1ecd2fbb714942b128547f8f16ac528dbf)) ## [2.2.0](https://github.com/webhippie/po_to_json/compare/v2.1.2...v2.2.0) (2025-11-10) ### Features * implement generate_for_json method ([aa8a13a](https://github.com/webhippie/po_to_json/commit/aa8a13ab8e2784ea23b889b775c6c700eb0b7821)) ## [2.1.2](https://github.com/webhippie/po_to_json/compare/v2.1.1...v2.1.2) (2025-10-13) ### Bugfixes * **patch:** update dependency ruby to v3.4.7 ([#41](https://github.com/webhippie/po_to_json/issues/41)) ([a251f47](https://github.com/webhippie/po_to_json/commit/a251f475ab7f66410c90283f3a19f821e47d9290)) ## [2.1.1](https://github.com/webhippie/po_to_json/compare/v2.1.0...v2.1.1) (2025-09-22) ### Bugfixes * **patch:** update dependency ruby to v3.4.6 ([#38](https://github.com/webhippie/po_to_json/issues/38)) ([3934def](https://github.com/webhippie/po_to_json/commit/3934defc08f0c6b132b75a8f2a75ecb9ec95df3f)) ## [2.1.0](https://github.com/webhippie/po_to_json/compare/v2.0.0...v2.1.0) (2025-09-12) ### Features * allow installation of more current listen version and ignore it for renovate ([c14cd42](https://github.com/webhippie/po_to_json/commit/c14cd42794536e335a97cbace1cb237f5d116451)) * integrate automated release process ([70f4f6d](https://github.com/webhippie/po_to_json/commit/70f4f6dbffc9dee4b0874c1e5bea3d83f35abc64)) * update rubocop rules and test cases ([7686d98](https://github.com/webhippie/po_to_json/commit/7686d98f1e6a93922c17961e7d17fa8e6b7e12a8)) ### Bugfixes * always download via https from rubygems ([5c14652](https://github.com/webhippie/po_to_json/commit/5c14652bb2d334ba94beed35f33b20d267cdd22f)) ## [2.0.0](https://github.com/webhippie/po_to_json/releases/tag/v2.0.0) - 2023-07-18 * Fix escape double quote in msgid (@chaomao) ## [1.1.0](https://github.com/webhippie/po_to_json/releases/tag/v1.0.1) - 2023-04-28 * Optionally remove var keyword to use a global (@illiatdesdindes) ## [1.0.1](https://github.com/webhippie/po_to_json/releases/tag/v1.0.1) - 2015-11-03 * Stop using bundler within the core lib (@tboerger) ## [1.0.0](https://github.com/webhippie/po_to_json/releases/tag/v1.0.0) - 2015-03-19 * BREAKING: Made result compatible to current Jed (#4) ## [0.1.0](https://github.com/webhippie/po_to_json/releases/tag/v0.1.0) - 2015-02-19 * Transfer from github.com/nubis/po_to_json (@tboerger) * Added TravisCI, Rubocop and Coveralls (@tboerger) * Updated structure to my opinionated gem style (@tboerger) webhippie-po_to_json-f2b2a61/Gemfile000066400000000000000000000032401517363432300175430ustar00rootroot00000000000000# frozen_string_literal: true # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # source "https://rubygems.org" gemspec gem "json", "~> #{ENV["JSON_VERSION"]}" if ENV["JSON_VERSION"] group :development do gem "guard", require: false gem "guard-rspec", require: false gem "guard-rubocop", require: false gem "bundler" gem "listen", ">= 3.0.7" gem "rake" gem "rspec" gem "yard" end group :test do gem "rubocop", require: false gem "simplecov", require: false end instance_eval(File.read("Gemfile.local")) if File.exist? "Gemfile.local" webhippie-po_to_json-f2b2a61/LICENSE000066400000000000000000000022171517363432300172600ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2012-2015 Dropmysite.com Copyright (c) 2015 Webhippie Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. webhippie-po_to_json-f2b2a61/README.md000066400000000000000000000063551517363432300175410ustar00rootroot00000000000000# po_to_json [![Test Status](https://github.com/webhippie/po_to_json/actions/workflows/testing.yml/badge.svg)](https://github.com/webhippie/po_to_json/actions/workflows/testing.yaml) [![Join the Matrix chat at https://matrix.to/#/#webhippie:matrix.org](https://img.shields.io/badge/matrix-%23webhippie%3Amatrix.org-7bc9a4.svg)](https://matrix.to/#/#webhippie:matrix.org) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/6e015952f83d42d4bfc7e335d856554a)](https://app.codacy.com/gh/webhippie/po_to_json/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [![Gem Version](https://badge.fury.io/rb/po_to_json.svg)](https://badge.fury.io/rb/po_to_json) Convert gettext PO files to JSON to use in your javascript app, based on po2json.pl by [DuckDuckGo, Inc.](http://duckduckgo.com/). Ideally you'll use this on a Rake task that creates JSON versions of your PO files, which can later be used from javascript with [Jed](http://slexaxton.github.io/Jed/) ## Versions For a list of the tested and supported Ruby and JSON versions please take a look at the [wokflow][workflow]. ## Installation ```ruby gem 'po_to_json', '~> 3.0.3' ``` ## Versioning This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions. As a result of this policy, you can (and should) specify a dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision. For example: ```ruby spec.add_dependency 'po_to_json', '~> 3.0.3' ``` ## Usage Most common use would be to generate a Jed ready javascript file. For example, in a Rails project: ```ruby require 'po_to_json' json = PoToJson.new( Rails.root.join('locale', 'de', 'app.po') ).generate_for_jed('de') Rails.root.join( 'app', 'assets', 'javascripts', 'locale', 'de', 'app.js' ).write(json) ``` If you need a pretty json, add `pretty: true` to `generate_for_jed`, like the following example: ```ruby require 'po_to_json' json = PoToJson.new( Rails.root.join('locale', 'de', 'app.po') ).generate_for_jed('de', pretty: true) Rails.root.join( 'app', 'assets', 'javascripts', 'locale', 'de', 'app.js' ).write(json) ``` The javascript file generated has a global "locales" object with an attribute corresponding to the generated language: ```javascript i18n = new Jed(locales['de']) i18n.gettext('Hello World') // Should evaluate to 'Hallo Welt' ``` ## Contributing Fork -> Patch -> Spec -> Push -> Pull Request ## Authors * [Thomas Boerger](https://github.com/tboerger) * [Nubis](https://github.com/nubis) * [Other contributors](https://github.com/webhippie/po_to_json/graphs/contributors) ## License MIT ## Copyright ``` Copyright (c) 2012-2015 Dropmysite.com Copyright (c) 2015 Webhippie ``` [workflow]: https://github.com/webhippie/po_to_json/blob/master/.github/workflows/testing.yml [semver]: http://semver.org [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint webhippie-po_to_json-f2b2a61/Rakefile000066400000000000000000000027731517363432300177270ustar00rootroot00000000000000# frozen_string_literal: true # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # begin require "bundler" Bundler::GemHelper.install_tasks rescue LoadError warn "Failed to load bundler tasks" end require "rubocop/rake_task" RuboCop::RakeTask.new require "yard" YARD::Rake::YardocTask.new require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) task default: [:spec, :rubocop] webhippie-po_to_json-f2b2a61/flake.lock000066400000000000000000000721421517363432300202130ustar00rootroot00000000000000{ "nodes": { "cachix": { "inputs": { "devenv": [ "devenv" ], "flake-compat": [ "devenv", "flake-compat" ], "git-hooks": [ "devenv", "git-hooks" ], "nixpkgs": [ "devenv", "nixpkgs" ] }, "locked": { "lastModified": 1774017633, "narHash": "sha256-CWhnwL2M83/ItapPVeJqCevRoQttesYxJ1h0Mo6ZCXs=", "owner": "cachix", "repo": "cachix", "rev": "e8be573b417f3daa3dd4cb9052178f848e0c9d1d", "type": "github" }, "original": { "owner": "cachix", "ref": "latest", "repo": "cachix", "type": "github" } }, "cachix_2": { "inputs": { "devenv": [ "devenv", "crate2nix" ], "flake-compat": [ "devenv", "crate2nix" ], "git-hooks": "git-hooks", "nixpkgs": "nixpkgs" }, "locked": { "lastModified": 1767714506, "narHash": "sha256-WaTs0t1CxhgxbIuvQ97OFhDTVUGd1HA+KzLZUZBhe0s=", "owner": "cachix", "repo": "cachix", "rev": "894c649f0daaa38bbcfb21de64be47dfa7cd0ec9", "type": "github" }, "original": { "owner": "cachix", "ref": "latest", "repo": "cachix", "type": "github" } }, "cachix_3": { "inputs": { "devenv": [ "devenv", "crate2nix", "crate2nix_stable" ], "flake-compat": [ "devenv", "crate2nix", "crate2nix_stable" ], "git-hooks": "git-hooks_2", "nixpkgs": "nixpkgs_2" }, "locked": { "lastModified": 1767714506, "narHash": "sha256-WaTs0t1CxhgxbIuvQ97OFhDTVUGd1HA+KzLZUZBhe0s=", "owner": "cachix", "repo": "cachix", "rev": "894c649f0daaa38bbcfb21de64be47dfa7cd0ec9", "type": "github" }, "original": { "owner": "cachix", "ref": "latest", "repo": "cachix", "type": "github" } }, "crate2nix": { "inputs": { "cachix": "cachix_2", "crate2nix_stable": "crate2nix_stable", "devshell": "devshell_2", "flake-compat": "flake-compat_2", "flake-parts": "flake-parts_2", "nix-test-runner": "nix-test-runner_2", "nixpkgs": [ "devenv", "nixpkgs" ], "pre-commit-hooks": "pre-commit-hooks_2" }, "locked": { "lastModified": 1772186516, "narHash": "sha256-8s28pzmQ6TOIUzznwFibtW1CMieMUl1rYJIxoQYor58=", "owner": "rossng", "repo": "crate2nix", "rev": "ba5dd398e31ee422fbe021767eb83b0650303a6e", "type": "github" }, "original": { "owner": "rossng", "repo": "crate2nix", "rev": "ba5dd398e31ee422fbe021767eb83b0650303a6e", "type": "github" } }, "crate2nix_stable": { "inputs": { "cachix": "cachix_3", "crate2nix_stable": [ "devenv", "crate2nix", "crate2nix_stable" ], "devshell": "devshell", "flake-compat": "flake-compat", "flake-parts": "flake-parts", "nix-test-runner": "nix-test-runner", "nixpkgs": "nixpkgs_3", "pre-commit-hooks": "pre-commit-hooks" }, "locked": { "lastModified": 1769627083, "narHash": "sha256-SUuruvw1/moNzCZosHaa60QMTL+L9huWdsCBN6XZIic=", "owner": "nix-community", "repo": "crate2nix", "rev": "7c33e664668faecf7655fa53861d7a80c9e464a2", "type": "github" }, "original": { "owner": "nix-community", "ref": "0.15.0", "repo": "crate2nix", "type": "github" } }, "devenv": { "inputs": { "cachix": "cachix", "crate2nix": "crate2nix", "flake-compat": "flake-compat_3", "flake-parts": "flake-parts_3", "ghostty": "ghostty", "git-hooks": "git-hooks_3", "nix": "nix", "nixd": "nixd", "nixpkgs": "nixpkgs_6", "rust-overlay": "rust-overlay" }, "locked": { "lastModified": 1777273559, "narHash": "sha256-k1yiflgtLJJAN0u1qlJC3gmf4rxnO+5U9rwVIlq3ebM=", "owner": "cachix", "repo": "devenv", "rev": "d31845dd5d9573ed611686c1f368eb8af41010ee", "type": "github" }, "original": { "owner": "cachix", "repo": "devenv", "type": "github" } }, "devshell": { "inputs": { "nixpkgs": [ "devenv", "crate2nix", "crate2nix_stable", "nixpkgs" ] }, "locked": { "lastModified": 1768818222, "narHash": "sha256-460jc0+CZfyaO8+w8JNtlClB2n4ui1RbHfPTLkpwhU8=", "owner": "numtide", "repo": "devshell", "rev": "255a2b1725a20d060f566e4755dbf571bbbb5f76", "type": "github" }, "original": { "owner": "numtide", "repo": "devshell", "type": "github" } }, "devshell_2": { "inputs": { "nixpkgs": [ "devenv", "crate2nix", "nixpkgs" ] }, "locked": { "lastModified": 1768818222, "narHash": "sha256-460jc0+CZfyaO8+w8JNtlClB2n4ui1RbHfPTLkpwhU8=", "owner": "numtide", "repo": "devshell", "rev": "255a2b1725a20d060f566e4755dbf571bbbb5f76", "type": "github" }, "original": { "owner": "numtide", "repo": "devshell", "type": "github" } }, "flake-compat": { "locked": { "lastModified": 1733328505, "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", "revCount": 69, "type": "tarball", "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.1.0/01948eb7-9cba-704f-bbf3-3fa956735b52/source.tar.gz" }, "original": { "type": "tarball", "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" } }, "flake-compat_2": { "locked": { "lastModified": 1733328505, "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", "revCount": 69, "type": "tarball", "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.1.0/01948eb7-9cba-704f-bbf3-3fa956735b52/source.tar.gz" }, "original": { "type": "tarball", "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" } }, "flake-compat_3": { "flake": false, "locked": { "lastModified": 1767039857, "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", "owner": "edolstra", "repo": "flake-compat", "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", "type": "github" }, "original": { "owner": "edolstra", "repo": "flake-compat", "type": "github" } }, "flake-compat_4": { "flake": false, "locked": { "lastModified": 1761588595, "narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=", "owner": "edolstra", "repo": "flake-compat", "rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5", "type": "github" }, "original": { "owner": "edolstra", "repo": "flake-compat", "type": "github" } }, "flake-compat_5": { "flake": false, "locked": { "lastModified": 1767039857, "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", "owner": "NixOS", "repo": "flake-compat", "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", "type": "github" }, "original": { "owner": "NixOS", "repo": "flake-compat", "type": "github" } }, "flake-parts": { "inputs": { "nixpkgs-lib": [ "devenv", "crate2nix", "crate2nix_stable", "nixpkgs" ] }, "locked": { "lastModified": 1768135262, "narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=", "owner": "hercules-ci", "repo": "flake-parts", "rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac", "type": "github" }, "original": { "owner": "hercules-ci", "repo": "flake-parts", "type": "github" } }, "flake-parts_2": { "inputs": { "nixpkgs-lib": [ "devenv", "crate2nix", "nixpkgs" ] }, "locked": { "lastModified": 1768135262, "narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=", "owner": "hercules-ci", "repo": "flake-parts", "rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac", "type": "github" }, "original": { "owner": "hercules-ci", "repo": "flake-parts", "type": "github" } }, "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "devenv", "nixpkgs" ] }, "locked": { "lastModified": 1775087534, "narHash": "sha256-91qqW8lhL7TLwgQWijoGBbiD4t7/q75KTi8NxjVmSmA=", "owner": "hercules-ci", "repo": "flake-parts", "rev": "3107b77cd68437b9a76194f0f7f9c55f2329ca5b", "type": "github" }, "original": { "owner": "hercules-ci", "repo": "flake-parts", "type": "github" } }, "flake-parts_4": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" }, "locked": { "lastModified": 1775087534, "narHash": "sha256-91qqW8lhL7TLwgQWijoGBbiD4t7/q75KTi8NxjVmSmA=", "owner": "hercules-ci", "repo": "flake-parts", "rev": "3107b77cd68437b9a76194f0f7f9c55f2329ca5b", "type": "github" }, "original": { "owner": "hercules-ci", "repo": "flake-parts", "type": "github" } }, "ghostty": { "inputs": { "flake-compat": "flake-compat_4", "home-manager": "home-manager", "nixpkgs": "nixpkgs_4", "systems": "systems", "zig": "zig", "zon2nix": "zon2nix" }, "locked": { "lastModified": 1776365871, "narHash": "sha256-lAFTUeJy7AT4V+t8/HlMM7O5z6W+G4eUhzRoh3ZdZu8=", "owner": "cachix", "repo": "ghostty", "rev": "d882f9106d15c213239b8916083835263d4fb9bc", "type": "github" }, "original": { "owner": "cachix", "ref": "cachix-upstream", "repo": "ghostty", "type": "github" } }, "git-hooks": { "inputs": { "flake-compat": [ "devenv", "crate2nix", "cachix", "flake-compat" ], "gitignore": "gitignore", "nixpkgs": [ "devenv", "crate2nix", "cachix", "nixpkgs" ] }, "locked": { "lastModified": 1765404074, "narHash": "sha256-+ZDU2d+vzWkEJiqprvV5PR26DVFN2vgddwG5SnPZcUM=", "owner": "cachix", "repo": "git-hooks.nix", "rev": "2d6f58930fbcd82f6f9fd59fb6d13e37684ca529", "type": "github" }, "original": { "owner": "cachix", "repo": "git-hooks.nix", "type": "github" } }, "git-hooks_2": { "inputs": { "flake-compat": [ "devenv", "crate2nix", "crate2nix_stable", "cachix", "flake-compat" ], "gitignore": "gitignore_2", "nixpkgs": [ "devenv", "crate2nix", "crate2nix_stable", "cachix", "nixpkgs" ] }, "locked": { "lastModified": 1765404074, "narHash": "sha256-+ZDU2d+vzWkEJiqprvV5PR26DVFN2vgddwG5SnPZcUM=", "owner": "cachix", "repo": "git-hooks.nix", "rev": "2d6f58930fbcd82f6f9fd59fb6d13e37684ca529", "type": "github" }, "original": { "owner": "cachix", "repo": "git-hooks.nix", "type": "github" } }, "git-hooks_3": { "inputs": { "flake-compat": [ "devenv", "flake-compat" ], "gitignore": "gitignore_5", "nixpkgs": [ "devenv", "nixpkgs" ] }, "locked": { "lastModified": 1775585728, "narHash": "sha256-8Psjt+TWvE4thRKktJsXfR6PA/fWWsZ04DVaY6PUhr4=", "owner": "cachix", "repo": "git-hooks.nix", "rev": "580633fa3fe5fc0379905986543fd7495481913d", "type": "github" }, "original": { "owner": "cachix", "repo": "git-hooks.nix", "type": "github" } }, "git-hooks_4": { "inputs": { "flake-compat": "flake-compat_5", "gitignore": "gitignore_6", "nixpkgs": "nixpkgs_7" }, "locked": { "lastModified": 1776796298, "narHash": "sha256-PcRvlWayisPSjd0UcRQbhG8Oqw78AcPE6x872cPRHN8=", "owner": "cachix", "repo": "git-hooks.nix", "rev": "3cfd774b0a530725a077e17354fbdb87ea1c4aad", "type": "github" }, "original": { "owner": "cachix", "repo": "git-hooks.nix", "type": "github" } }, "gitignore": { "inputs": { "nixpkgs": [ "devenv", "crate2nix", "cachix", "git-hooks", "nixpkgs" ] }, "locked": { "lastModified": 1709087332, "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", "owner": "hercules-ci", "repo": "gitignore.nix", "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { "owner": "hercules-ci", "repo": "gitignore.nix", "type": "github" } }, "gitignore_2": { "inputs": { "nixpkgs": [ "devenv", "crate2nix", "crate2nix_stable", "cachix", "git-hooks", "nixpkgs" ] }, "locked": { "lastModified": 1709087332, "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", "owner": "hercules-ci", "repo": "gitignore.nix", "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { "owner": "hercules-ci", "repo": "gitignore.nix", "type": "github" } }, "gitignore_3": { "inputs": { "nixpkgs": [ "devenv", "crate2nix", "crate2nix_stable", "pre-commit-hooks", "nixpkgs" ] }, "locked": { "lastModified": 1709087332, "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", "owner": "hercules-ci", "repo": "gitignore.nix", "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { "owner": "hercules-ci", "repo": "gitignore.nix", "type": "github" } }, "gitignore_4": { "inputs": { "nixpkgs": [ "devenv", "crate2nix", "pre-commit-hooks", "nixpkgs" ] }, "locked": { "lastModified": 1709087332, "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", "owner": "hercules-ci", "repo": "gitignore.nix", "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { "owner": "hercules-ci", "repo": "gitignore.nix", "type": "github" } }, "gitignore_5": { "inputs": { "nixpkgs": [ "devenv", "git-hooks", "nixpkgs" ] }, "locked": { "lastModified": 1709087332, "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", "owner": "hercules-ci", "repo": "gitignore.nix", "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { "owner": "hercules-ci", "repo": "gitignore.nix", "type": "github" } }, "gitignore_6": { "inputs": { "nixpkgs": [ "git-hooks", "nixpkgs" ] }, "locked": { "lastModified": 1709087332, "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", "owner": "hercules-ci", "repo": "gitignore.nix", "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { "owner": "hercules-ci", "repo": "gitignore.nix", "type": "github" } }, "home-manager": { "inputs": { "nixpkgs": [ "devenv", "ghostty", "nixpkgs" ] }, "locked": { "lastModified": 1770586272, "narHash": "sha256-Ucci8mu8QfxwzyfER2DQDbvW9t1BnTUJhBmY7ybralo=", "owner": "nix-community", "repo": "home-manager", "rev": "b1f916ba052341edc1f80d4b2399f1092a4873ca", "type": "github" }, "original": { "owner": "nix-community", "repo": "home-manager", "type": "github" } }, "nix": { "inputs": { "flake-compat": [ "devenv", "flake-compat" ], "flake-parts": [ "devenv", "flake-parts" ], "git-hooks-nix": [ "devenv", "git-hooks" ], "nixpkgs": [ "devenv", "nixpkgs" ], "nixpkgs-23-11": [ "devenv" ], "nixpkgs-regression": [ "devenv" ] }, "locked": { "lastModified": 1776511668, "narHash": "sha256-g2KEBuHpc3a56c+jPcg0+w6LSuIj6f+zzdztLCOyIhc=", "owner": "cachix", "repo": "nix", "rev": "42d4b7de21c15f28c568410f4383fa06a8458a40", "type": "github" }, "original": { "owner": "cachix", "ref": "devenv-2.34", "repo": "nix", "type": "github" } }, "nix-test-runner": { "flake": false, "locked": { "lastModified": 1588761593, "narHash": "sha256-FKJykltAN/g3eIceJl4SfDnnyuH2jHImhMrXS2KvGIs=", "owner": "stoeffel", "repo": "nix-test-runner", "rev": "c45d45b11ecef3eb9d834c3b6304c05c49b06ca2", "type": "github" }, "original": { "owner": "stoeffel", "repo": "nix-test-runner", "type": "github" } }, "nix-test-runner_2": { "flake": false, "locked": { "lastModified": 1588761593, "narHash": "sha256-FKJykltAN/g3eIceJl4SfDnnyuH2jHImhMrXS2KvGIs=", "owner": "stoeffel", "repo": "nix-test-runner", "rev": "c45d45b11ecef3eb9d834c3b6304c05c49b06ca2", "type": "github" }, "original": { "owner": "stoeffel", "repo": "nix-test-runner", "type": "github" } }, "nixd": { "inputs": { "flake-parts": [ "devenv", "flake-parts" ], "nixpkgs": "nixpkgs_5", "treefmt-nix": "treefmt-nix" }, "locked": { "lastModified": 1776341634, "narHash": "sha256-L//ltP2o5+BnuK+KEulbi2gGeDpyyex6SkXLZcGQ/Ac=", "owner": "nix-community", "repo": "nixd", "rev": "951e98e2025c47614f5249556ecf509b0ea35b51", "type": "github" }, "original": { "owner": "nix-community", "repo": "nixd", "type": "github" } }, "nixpkgs": { "locked": { "lastModified": 1765186076, "narHash": "sha256-hM20uyap1a0M9d344I692r+ik4gTMyj60cQWO+hAYP8=", "owner": "NixOS", "repo": "nixpkgs", "rev": "addf7cf5f383a3101ecfba091b98d0a1263dc9b8", "type": "github" }, "original": { "owner": "NixOS", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs-lib": { "locked": { "lastModified": 1774748309, "narHash": "sha256-+U7gF3qxzwD5TZuANzZPeJTZRHS29OFQgkQ2kiTJBIQ=", "owner": "nix-community", "repo": "nixpkgs.lib", "rev": "333c4e0545a6da976206c74db8773a1645b5870a", "type": "github" }, "original": { "owner": "nix-community", "repo": "nixpkgs.lib", "type": "github" } }, "nixpkgs-src": { "flake": false, "locked": { "lastModified": 1775888245, "narHash": "sha256-nwASzrRDD1JBEu/o8ekKYEXm/oJW6EMCzCRdrwcLe90=", "owner": "NixOS", "repo": "nixpkgs", "rev": "13043924aaa7375ce482ebe2494338e058282925", "type": "github" }, "original": { "owner": "NixOS", "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_2": { "locked": { "lastModified": 1765186076, "narHash": "sha256-hM20uyap1a0M9d344I692r+ik4gTMyj60cQWO+hAYP8=", "owner": "NixOS", "repo": "nixpkgs", "rev": "addf7cf5f383a3101ecfba091b98d0a1263dc9b8", "type": "github" }, "original": { "owner": "NixOS", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_3": { "locked": { "lastModified": 1769433173, "narHash": "sha256-Gf1dFYgD344WZ3q0LPlRoWaNdNQq8kSBDLEWulRQSEs=", "owner": "NixOS", "repo": "nixpkgs", "rev": "13b0f9e6ac78abbbb736c635d87845c4f4bee51b", "type": "github" }, "original": { "owner": "NixOS", "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_4": { "locked": { "lastModified": 1772963539, "narHash": "sha256-G4+9cEu8XSqEWYUB6iRgDfrg53av6yyRwAKhSeKbUVw=", "rev": "9dcb002ca1690658be4a04645215baea8b95f31d", "type": "tarball", "url": "https://releases.nixos.org/nixos/unstable/nixos-26.05pre960399.9dcb002ca169/nixexprs.tar.xz" }, "original": { "type": "tarball", "url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz" } }, "nixpkgs_5": { "locked": { "lastModified": 1772963539, "narHash": "sha256-G4+9cEu8XSqEWYUB6iRgDfrg53av6yyRwAKhSeKbUVw=", "rev": "9dcb002ca1690658be4a04645215baea8b95f31d", "type": "tarball", "url": "https://releases.nixos.org/nixos/unstable/nixos-26.05pre960399.9dcb002ca169/nixexprs.tar.xz" }, "original": { "type": "tarball", "url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz" } }, "nixpkgs_6": { "inputs": { "nixpkgs-src": "nixpkgs-src" }, "locked": { "lastModified": 1776771808, "narHash": "sha256-FRpraDgknF5zoCYTi9CitoIaUYb/XGiXUuVqPg9AYB4=", "owner": "cachix", "repo": "devenv-nixpkgs", "rev": "3a3d4ac6ea3dbf2534ef988086348b7e140b92ad", "type": "github" }, "original": { "owner": "cachix", "ref": "rolling", "repo": "devenv-nixpkgs", "type": "github" } }, "nixpkgs_7": { "locked": { "lastModified": 1770073757, "narHash": "sha256-Vy+G+F+3E/Tl+GMNgiHl9Pah2DgShmIUBJXmbiQPHbI=", "owner": "NixOS", "repo": "nixpkgs", "rev": "47472570b1e607482890801aeaf29bfb749884f6", "type": "github" }, "original": { "owner": "NixOS", "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_8": { "locked": { "lastModified": 1776877367, "narHash": "sha256-EHq1/OX139R1RvBzOJ0aMRT3xnWyqtHBRUBuO1gFzjI=", "owner": "NixOS", "repo": "nixpkgs", "rev": "0726a0ecb6d4e08f6adced58726b95db924cef57", "type": "github" }, "original": { "owner": "NixOS", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "pre-commit-hooks": { "inputs": { "flake-compat": [ "devenv", "crate2nix", "crate2nix_stable", "flake-compat" ], "gitignore": "gitignore_3", "nixpkgs": [ "devenv", "crate2nix", "crate2nix_stable", "nixpkgs" ] }, "locked": { "lastModified": 1769069492, "narHash": "sha256-Efs3VUPelRduf3PpfPP2ovEB4CXT7vHf8W+xc49RL/U=", "owner": "cachix", "repo": "pre-commit-hooks.nix", "rev": "a1ef738813b15cf8ec759bdff5761b027e3e1d23", "type": "github" }, "original": { "owner": "cachix", "repo": "pre-commit-hooks.nix", "type": "github" } }, "pre-commit-hooks_2": { "inputs": { "flake-compat": [ "devenv", "crate2nix", "flake-compat" ], "gitignore": "gitignore_4", "nixpkgs": [ "devenv", "crate2nix", "nixpkgs" ] }, "locked": { "lastModified": 1769069492, "narHash": "sha256-Efs3VUPelRduf3PpfPP2ovEB4CXT7vHf8W+xc49RL/U=", "owner": "cachix", "repo": "pre-commit-hooks.nix", "rev": "a1ef738813b15cf8ec759bdff5761b027e3e1d23", "type": "github" }, "original": { "owner": "cachix", "repo": "pre-commit-hooks.nix", "type": "github" } }, "root": { "inputs": { "devenv": "devenv", "flake-parts": "flake-parts_4", "git-hooks": "git-hooks_4", "nixpkgs": "nixpkgs_8" } }, "rust-overlay": { "inputs": { "nixpkgs": [ "devenv", "nixpkgs" ] }, "locked": { "lastModified": 1776741231, "narHash": "sha256-k9G98qzn+7npROUaks8VqCFm7cFtEG8ulQLBBo5lItg=", "owner": "oxalica", "repo": "rust-overlay", "rev": "02061303f7c4c964f7b4584dabd9e985b4cd442b", "type": "github" }, "original": { "owner": "oxalica", "repo": "rust-overlay", "type": "github" } }, "systems": { "flake": false, "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "owner": "nix-systems", "repo": "default", "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "type": "github" }, "original": { "owner": "nix-systems", "repo": "default", "type": "github" } }, "treefmt-nix": { "inputs": { "nixpkgs": [ "devenv", "nixd", "nixpkgs" ] }, "locked": { "lastModified": 1775636079, "narHash": "sha256-pc20NRoMdiar8oPQceQT47UUZMBTiMdUuWrYu2obUP0=", "owner": "numtide", "repo": "treefmt-nix", "rev": "790751ff7fd3801feeaf96d7dc416a8d581265ba", "type": "github" }, "original": { "owner": "numtide", "repo": "treefmt-nix", "type": "github" } }, "zig": { "inputs": { "flake-compat": [ "devenv", "ghostty", "flake-compat" ], "nixpkgs": [ "devenv", "ghostty", "nixpkgs" ], "systems": [ "devenv", "ghostty", "systems" ] }, "locked": { "lastModified": 1773145353, "narHash": "sha256-dE8zx8WA54TRmFFQBvA48x/sXGDTP7YaDmY6nNKMAYw=", "owner": "mitchellh", "repo": "zig-overlay", "rev": "8666155d83bf792956a7c40915508e6d4b2b8716", "type": "github" }, "original": { "owner": "mitchellh", "repo": "zig-overlay", "type": "github" } }, "zig_2": { "inputs": { "nixpkgs": [ "devenv", "ghostty", "zon2nix", "nixpkgs" ] }, "locked": { "lastModified": 1776208985, "narHash": "sha256-IOuRFpbeQ9jSk54OURX5yvjoC759ujgSNjkMKpChdDA=", "ref": "refs/heads/main", "rev": "e8ee348125247e7bd74932cc42ac92df90961d5b", "revCount": 1666, "type": "git", "url": "https://codeberg.org/jcollie/zig-overlay.git" }, "original": { "type": "git", "url": "https://codeberg.org/jcollie/zig-overlay.git" } }, "zon2nix": { "inputs": { "nixpkgs": [ "devenv", "ghostty", "nixpkgs" ], "zig": "zig_2" }, "locked": { "lastModified": 1776269939, "narHash": "sha256-tOGsI1d1Xk1PYapQJ/ByG0utbWXJasIna/fUib+/b5A=", "owner": "jcollie", "repo": "zon2nix", "rev": "cc467a77c2ebcd9aab84024196abfc37eaf1007d", "type": "github" }, "original": { "owner": "jcollie", "ref": "main", "repo": "zon2nix", "type": "github" } } }, "root": "root", "version": 7 } webhippie-po_to_json-f2b2a61/flake.nix000066400000000000000000000031411517363432300200520ustar00rootroot00000000000000{ description = "Nix flake for development"; inputs = { nixpkgs = { url = "github:NixOS/nixpkgs/nixos-unstable"; }; devenv = { url = "github:cachix/devenv"; }; flake-parts = { url = "github:hercules-ci/flake-parts"; }; git-hooks = { url = "github:cachix/git-hooks.nix"; }; }; outputs = inputs@{ flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } { imports = [ inputs.devenv.flakeModule inputs.git-hooks.flakeModule ]; systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; perSystem = { config, self', inputs', pkgs, system, ... }: { imports = [ { _module.args.pkgs = import inputs.nixpkgs { inherit system; config.allowUnfree = true; }; } ]; devenv = { shells = { default = { git-hooks = { hooks = { nixfmt-rfc-style = { enable = true; }; }; }; languages = { ruby = { enable = true; package = pkgs.ruby_3_4; }; }; packages = with pkgs; [ nixfmt-rfc-style ]; }; }; }; }; }; } webhippie-po_to_json-f2b2a61/lib/000077500000000000000000000000001517363432300170175ustar00rootroot00000000000000webhippie-po_to_json-f2b2a61/lib/po_to_json.rb000066400000000000000000000144541517363432300215250ustar00rootroot00000000000000# frozen_string_literal: true # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # gem "json", version: ">= 1.6.0" require "json" class PoToJson autoload :Version, File.expand_path("po_to_json/version", __dir__) attr_accessor :files, :glue, :options def initialize(files, glue = "|") @files = files @glue = glue end def generate_for_jed(language, overwrite = {}) generated = generate_for_json(language, overwrite) return generated if options[:just_json] [ @options[:variable_locale_scope] ? "var" : "", "#{@options[:variable]} = #{@options[:variable]} || {};", "#{@options[:variable]}['#{@options[:language]}'] = #{generated};" ].join(" ") end def generate_for_json(language, overwrite = {}) @options = parse_options(overwrite.merge(language: language)) @parsed ||= inject_meta(parse_document) build_json_for(build_jed_for(@parsed)) end def parse_document reset_buffer reset_result File.foreach(files) do |line| matches_values_for(line.chomp) end flush_buffer parse_header values end def flush_buffer return unless buffer[:msgid] build_trans assign_trans reset_buffer end def parse_header return if reject_header values[""][0].split("\\n").each do |line| next if line.empty? build_header_for(line) end values[""] = headers end def reject_header if values[""].nil? || values[""][0].nil? values[""] = {} true else false end end protected def trans @trans ||= [] end def errors @errors ||= [] end def values @values ||= {} end def buffer @buffer ||= {} end def headers @headers ||= {} end def lastkey @lastkey ||= "" end def reset_result @values = {} @errors = [] end def reset_buffer @buffer = {} @trans = [] @lastkey = "" end def detect_ctxt msgctxt = buffer[:msgctxt] msgid = buffer[:msgid] if msgctxt && !msgctxt.empty? [msgctxt, glue, msgid].join else msgid end end def detect_plural plural = buffer[:msgid_plural] plural if plural && !plural.empty? end def build_trans buffer.each do |key, string| trans[$1.to_i] = string if key.to_s =~ /^msgstr_(\d+)/ end # trans.unshift(detect_plural) if detect_plural end def assign_trans values[detect_ctxt] = trans unless trans.empty? end def push_buffer(value, key = nil) value = $1 if value =~ /^"(.*)"/ value.gsub!('\"', "\"") if key.nil? buffer[lastkey] = [ buffer[lastkey], value ].join else buffer[key] = value @lastkey = key end end def parse_options(options) defaults = { pretty: false, domain: "app", variable: "locales", variable_locale_scope: true } defaults.merge(options) end def inject_meta(hash) hash[""]["lang"] ||= options[:language] hash[""]["domain"] ||= options[:domain] hash[""]["plural_forms"] ||= hash[""]["Plural-Forms"] hash end def build_header_for(line) if line =~ /(.*?):(.*)/ key = $1 value = $2 if headers.key? key errors.push "Duplicate header: #{line}" elsif key =~ /#-#-#-#-#/ errors.push "Marked header: #{line}" else headers[key] = value.strip end else errors.push "Malformed header: #{line}" end end def build_json_for(hash) if options[:pretty] JSON.pretty_generate(hash) else JSON.generate(hash) end end def build_jed_for(hash) { domain: options[:domain], locale_data: { options[:domain] => hash } } end def matches_values_for(line) return if generic_rejects? line return if generic_detects? line return if iterate_detects_for(line) errors.push "Strange line #{line}" end def iterate_detects_for(line) specific_detects.each do |detect| match = line.match(detect[:regex]) if match if detect[:index] push_buffer(match[detect[:index]], detect[:key].call(match)) else push_buffer(line) end return true end end false end def generic_rejects?(line) if line.match(/^$/) || line.match(/^(#[^~]|\#$)/) flush_buffer && true else false end end def generic_detects?(line) match = line.match(/^(?:#~ )?msgctxt\s+(.*)/) if match push_buffer( match[1], :msgctxt ) return true end false end def specific_detects [{ regex: /^(?:#~ )?msgctxt\s+(.*)/, index: 1, key: proc { :msgctxt } }, { regex: /^(?:#~ )?msgid\s+(.*)/, index: 1, key: proc { :msgid } }, { regex: /^(?:#~ )?msgid_plural\s+(.*)/, index: 1, key: proc { :msgid_plural } }, { regex: /^(?:#~ )?msgstr\s+(.*)/, index: 1, key: proc { :msgstr_0 } }, { regex: /^(?:#~ )?msgstr\[0\]\s+(.*)/, index: 1, key: proc { :msgstr_0 } }, { regex: /^(?:#~ )?msgstr\[(\d+)\]\s+(.*)/, index: 2, key: proc { |m| :"msgstr_#{m[1]}" } }, { regex: /^(?:#~ )?"/, index: nil }] end end webhippie-po_to_json-f2b2a61/lib/po_to_json/000077500000000000000000000000001517363432300211705ustar00rootroot00000000000000webhippie-po_to_json-f2b2a61/lib/po_to_json/version.rb000066400000000000000000000023611517363432300232040ustar00rootroot00000000000000# frozen_string_literal: true # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # class PoToJson VERSION = "3.0.3".freeze end webhippie-po_to_json-f2b2a61/po_to_json.gemspec000066400000000000000000000037621517363432300217770ustar00rootroot00000000000000# frozen_string_literal: true # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # $LOAD_PATH.push File.expand_path("lib", __dir__) require "po_to_json/version" Gem::Specification.new do |s| s.name = "po_to_json" s.version = PoToJson::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Thomas Boerger", "Nubis"] s.email = ["thomas@webhippie.de", "nubis@woobiz.com.ar"] s.summary = <<-EOF Convert gettext PO files to JSON EOF s.description = <<-EOF Convert gettext PO files to JSON objects so that you can use it in your application. EOF s.homepage = "https://github.com/webhippie/po_to_json" s.license = "MIT" s.files = ["CHANGELOG.md", "README.md", "LICENSE"] s.files += Dir.glob("lib/**/*") s.require_paths = ["lib"] s.required_ruby_version = ">= 1.9.3" s.metadata["rubygems_mfa_required"] = "true" s.add_dependency "json", ">= 1.6.0" end webhippie-po_to_json-f2b2a61/spec/000077500000000000000000000000001517363432300172035ustar00rootroot00000000000000webhippie-po_to_json-f2b2a61/spec/fixtures/000077500000000000000000000000001517363432300210545ustar00rootroot00000000000000webhippie-po_to_json-f2b2a61/spec/fixtures/test.po000066400000000000000000000035271517363432300224020ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. msgid "" msgstr "" "Project-Id-Version: version 0.0.1\n" "POT-Creation-Date: 2009-02-26 19:50+0100\n" "PO-Revision-Date: 2011-12-04 18:54+0900\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: app/helpers/translation_helper.rb:3 msgid "%{relative_time} ago" msgstr "vor %{relative_time}" #: app/views/cars/show.html.erb:5 msgid "1 Axis" msgid_plural "%{num} Axis" msgstr[0] "1 Achse" msgstr[1] "%{num} Achsen" #: app/controllers/cars_controller.rb:47 msgid "Car was successfully created." msgstr "Auto wurde erfolgreich gespeichert" #: app/controllers/cars_controller.rb:64 msgid "Car was successfully updated." msgstr "Auto wurde erfolgreich aktualisiert" #: app/views/cars/show.html.erb:1 locale/model_attributes.rb:3 msgid "Car|Model" msgstr "Modell" msgid "Untranslated" msgstr "" #: app/views/cars/show.html.erb:3 locale/model_attributes.rb:4 msgid "Car|Wheels count" msgstr "Räderzahl" #: app/views/cars/show.html.erb:7 msgid "Created" msgstr "Erstellt" #: app/views/cars/show.html.erb:9 msgid "Month" msgstr "Monat" #: locale/model_attributes.rb:2 msgid "car" msgstr "Auto" #: locale/testlog_phrases.rb:2 msgid "this is a dynamic translation which was found!" msgstr "" "Dies ist eine dynamische Übersetzung, die " "gefunden wurde!" #: locale/test_escape.rb:2 msgid "You should escape '\\' as '\\\\'." msgstr "Du solltest '\\' als '\\\\' escapen." msgid "Umläüte" msgstr "Umlaute" msgid "contains double quote, say \"Hello\"" msgstr "contains double quote, say \"Hello\"" webhippie-po_to_json-f2b2a61/spec/po_to_json_spec.rb000066400000000000000000000130161517363432300227140ustar00rootroot00000000000000# frozen_string_literal: true # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # require "spec_helper" describe PoToJson do let(:po_to_json) do @subject = PoToJson.new( File.expand_path("fixtures/test.po", __dir__) ) end describe "parsing" do subject do po_to_json.parse_document end it "should find the last author" do expect(subject[""]["Last-Translator"]).to( eq("FULL NAME ") ) end it "should parse embedded variables" do expect(subject["%{relative_time} ago"]).to( eq(["vor %{relative_time}"]) ) end it "should match pluralizations" do expect(subject["1 Axis"]).to( eq(["1 Achse", "%{num} Achsen"]) ) end it "should match glued values" do expect(subject["Car|Model"]).to( eq(["Modell"]) ) end it "should match embedded glue" do expect(subject["Car|Wheels count"]).to( eq(["Räderzahl"]) ) end it "should return empty strings as well" do expect(subject["Untranslated"]).to( eq([""]) ) end it "should match german umlauts" do expect(subject["Umläüte"]).to( eq(["Umlaute"]) ) end it "should match escaped values" do expect(subject["You should escape '\\\\' as '\\\\\\\\'."]).to( eq(["Du solltest '\\\\' als '\\\\\\\\' escapen."]) ) end it "should match multiline translations" do expect(subject["this is a dynamic translation which was found!"]).to( eq(["Dies ist eine dynamische Übersetzung, die gefunden wurde!"]) ) end it "should match simple strings" do expect(subject["Car was successfully created."]).to( eq(["Auto wurde erfolgreich gespeichert"]) ) expect(subject["Car was successfully updated."]).to( eq(["Auto wurde erfolgreich aktualisiert"]) ) expect(subject["Created"]).to( eq(["Erstellt"]) ) expect(subject["Month"]).to( eq(["Monat"]) ) expect(subject["car"]).to( eq(["Auto"]) ) end it "should not espace double quote in msgid" do expect( subject["contains double quote, say \"Hello\""] ).to be_truthy end end describe "generate jed compatible" do describe "with minified output" do subject do po_to_json.generate_for_jed("de") end it "should output the var definition" do expect( subject.include?("var locales = locales || {}; locales['de'] = ") ).to be_truthy end it "should include domain string" do expect( subject.include?('"domain":"app"') ).to be_truthy end it "should include lang string" do expect( subject.include?('"lang":"de"') ).to be_truthy end it "should include pluralization" do val = '"plural_forms":"nplurals=2; plural=(n != 1);"' expect( subject.include?(val) ).to be_truthy end it "should include a single line break" do expect( subject.count("\n") ).to be < 1 end end context "with pretty output" do subject do po_to_json.generate_for_jed("de", pretty: true) end it "should output the var definition" do expect( subject.include?("var locales = locales || {}; locales['de'] = ") ).to be_truthy end it "should include domain string" do expect( subject.include?('"domain": "app"') ).to be_truthy end it "should include lang string" do expect( subject.include?('"lang": "de"') ).to be_truthy end it "should include pluralization" do val = '"plural_forms": "nplurals=2; plural=(n != 1);"' expect( subject.include?(val) ).to be_truthy end it "should include multiple line breaks" do expect( subject.count("\n") ).to be > 0 end end context "without locale scope variable" do subject do po_to_json.generate_for_jed("de", variable_locale_scope: false) end it "should output the var definition" do expect( subject.include?("locales = locales || {}; locales['de'] = ") ).to be_truthy end end end # describe "generate simple hashes" do # pending "have to be implemented" # end end webhippie-po_to_json-f2b2a61/spec/spec_helper.rb000066400000000000000000000027271517363432300220310ustar00rootroot00000000000000# frozen_string_literal: true # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # if ENV.key? "CODACY_PROJECT_TOKEN" begin require "codacy-coverage" Codacy::Reporter.start rescue StandardError puts "Failed to load codacy-coverage gem" end end require "po_to_json" require "rspec" RSpec.configure do |config| config.mock_with :rspec end