@abradley2/elm-i18next-gen
Advanced tools
Comparing version 1.0.0 to 2.0.0
{ | ||
"elm-codegen-version": "0.2.0", | ||
"elm-codegen-version": "0.5.0", | ||
"codegen-helpers": { | ||
@@ -7,5 +7,4 @@ "packages": { | ||
}, | ||
"local": [ | ||
] | ||
"local": [] | ||
} | ||
} |
{ | ||
"type": "application", | ||
"source-directories": [ | ||
"." | ||
".", | ||
"../src" | ||
], | ||
@@ -9,3 +10,3 @@ "elm-version": "0.19.1", | ||
"direct": { | ||
"abradley2/elm-i18next-gen": "2.0.2", | ||
"ChristophP/elm-i18next": "4.2.1", | ||
"elm/browser": "1.0.2", | ||
@@ -15,7 +16,8 @@ "elm/core": "1.0.5", | ||
"elm/json": "1.1.3", | ||
"mdgriffith/elm-codegen": "2.0.0" | ||
"elm/parser": "1.1.0", | ||
"elm-community/maybe-extra": "5.3.0", | ||
"mdgriffith/elm-codegen": "4.0.0", | ||
"s6o/elm-recase": "1.0.1" | ||
}, | ||
"indirect": { | ||
"ChristophP/elm-i18next": "4.2.1", | ||
"elm/parser": "1.1.0", | ||
"elm/regex": "1.0.0", | ||
@@ -27,6 +29,4 @@ "elm/time": "1.0.0", | ||
"elm-community/list-extra": "8.6.0", | ||
"elm-community/maybe-extra": "5.3.0", | ||
"miniBill/elm-unicode": "1.0.2", | ||
"rtfeldman/elm-hex": "1.0.0", | ||
"s6o/elm-recase": "1.0.1", | ||
"stil4m/elm-syntax": "7.2.9", | ||
@@ -33,0 +33,0 @@ "stil4m/structured-writer": "1.0.3", |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "2.0.2", | ||
"version": "2.0.5", | ||
"exposed-modules": [ | ||
@@ -9,0 +9,0 @@ "I18NextGen" |
{ | ||
"name": "@abradley2/elm-i18next-gen", | ||
"version": "1.0.0", | ||
"description": "Generate type-safe translations for Elm", | ||
"version": "2.0.0", | ||
"description": "An elm-codegen library for creating type-safe helper methods for the excellent ChristophP/elm-i18next package.", | ||
"main": "index.js", | ||
"bin": "./node_modules/.bin/elm-codegen", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/abradley2/elm-i18next-gen.git" | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Tony Bradley", | ||
"author": "", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/abradley2/elm-i18next-gen/issues" | ||
}, | ||
"homepage": "https://github.com/abradley2/elm-i18next-gen#readme", | ||
"dependencies": { | ||
"elm-codegen": "^0.2.0" | ||
"elm-codegen": "^0.5.0", | ||
"minimist": "^1.2.8" | ||
} | ||
} |
@@ -11,72 +11,17 @@ # Elm I18Next Code Generation | ||
## CLI Usage (Recommended) | ||
Use the cli via `npx @abradley2/elm-i18next-gen -- --flags-from="path/to/translations.en.json"` | ||
to generate the code for your translations. | ||
This simply proxies to `elm-codegen` without having to add a `codegen` directory to your current | ||
project. | ||
## Elm Codegen Usage | ||
* Follow the ["Getting Started" guide from elm-codegen](https://github.com/mdgriffith/elm-codegen/blob/main/guide/GettingStarted.md) | ||
* In your initialized codegen project, `elm install abradley2/elm-i18next-gen` | ||
```elm | ||
import I18Next.Gen | ||
import Gen.CodeGen.Generate as Generate | ||
import Json.Decode exposing (Value) | ||
In your project that consumes the generated code, you should `elm install ChristophP/elm-i18next`. | ||
This library generates code for usage with `ChristophP/elm-i18next`. | ||
main : Platform Value () () | ||
main = | ||
Generate.fromJson | ||
I18NextGen.flagsDecoder | ||
I18NextGen.files | ||
``` | ||
Consuming the module in this way allows you to have different code generation paths depending on dynamic flags. But if you're only | ||
generating code for translations, the above is sufficient. | ||
Then just run `elm-codegen`, supplying the translations file as flags. | ||
`npx elm-codegen run --flags-from="path/to/translations/en.json"` | ||
## Example | ||
You should have a root directory that contains your Elm application. From this directory you've called | ||
`npx elm-codegen init` and have something resembling the following: | ||
npx @abradley2/elm-i18next-gen --output=generated --translations=relative/path/to/translations.json | ||
``` | ||
elm-app/ | ||
|--assets/ | ||
| |--translations.en.json | ||
|--src/ | ||
| |--Main.elm | ||
|--codegen/ | ||
|--Generate.elm | ||
``` | ||
When you have followed the steps in the **Usage** section, running- | ||
This will create a directory "generated" containing a `Language.elm` file and a `Translations.elm` | ||
file, along with `Translations` sub modules based on the structure of your translations file. | ||
``` | ||
npx elm-codegen run --flags-from="assets/translations.en.json" | ||
``` | ||
-from your **elm-app** root should produce: | ||
``` | ||
elm-app/ | ||
|--assets/ | ||
| |--translations.en.json | ||
|--src/ | ||
| |--Main.elm | ||
|--codegen/ | ||
| |--Generate.elm | ||
|--generated/ | ||
|--Language.elm | ||
|--Translations.elm | ||
|--Translations/ | ||
``` | ||
A translations file like this, conforming to the [I18Next V2 specification](https://www.i18next.com/misc/json-format#i18next-json-v2): | ||
A translations file like should look something like this, | ||
conforming to the [I18Next V2 specification](https://www.i18next.com/misc/json-format#i18next-json-v2): | ||
```json | ||
@@ -89,3 +34,3 @@ { | ||
-will generate: | ||
This will generate the following: | ||
@@ -115,3 +60,3 @@ ```elm | ||
[ ( "" | ||
, I18Next.object | ||
, I18Next.object | ||
[ ( "generalGreeting", I18Next.string "Hello there" ) | ||
@@ -132,3 +77,3 @@ , ( "personalGreeting", I18Next.string "Hello {{name}}" ) | ||
This will create sub-modules in the `Translations` directory. | ||
This will create the sub-modules in the `Translations` directory. | ||
@@ -135,0 +80,0 @@ ## Recommended Pattern |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
3014507
41
100
2
2
2
86
2
+ Addedminimist@^1.2.8
+ Addedelm-codegen@0.5.3(transitive)
- Removedelm-codegen@0.2.0(transitive)
Updatedelm-codegen@^0.5.0