avaragado / riw Goto Github PK
View Code? Open in Web Editor NEWA console app and library to help you localise React apps in conjunction with react-intl
License: MIT License
A console app and library to help you localise React apps in conjunction with react-intl
License: MIT License
I just added riw
to a project I'm contributing to. (@avaragado - awesome work, thank you for making this! ๐) It's a TypeScript project, so right now there's a transpile-to-JS step that needs to happen before babel (invoked by riw) can extract the strings for localisation.
Since manually invoking the transpilation can easily be forgotten, I was wondering ... if there would be interest in a pre-babel hook implementation in riw that could be configured to run such transpile step automatically? If so I could contribute that in the near future.
Something in the following direction:
/* package.json */
{
"riw": {
"transpileCommand": "tsc -p . --target ES6 --module esnext --jsx preserve --outDir tmp/transpiled",
"sourceDirs": [
"tmp/transpiled/**/*.js",
"tmp/transpiled/**/*.jsx"
]
}
}
It would be great if this tool supported babel-plugin-react-intl-auto
. It allows id
s to be autogenerated based on the file's path.
I installed the plugin and added it to my .babelrc
, but it doesn't look like riw
is picking up the plugin.
.babelrc
{
"presets": ["react-app"],
"plugins": [
["react-intl-auto", {
"removePrefix": "src/",
"filebase": false
}]
]
}
I dug in a little bit, and it looks like riw
uses babel-plugin-react-intl
explicitly:
Would it be possible to include additional babel plugins, or am I missing something?
react-intl recently added support for arbitrary objects, as well as strings, as the value of a message descriptor's optional description
field.
riw currently supports only string values.
In riw, description strings are used as an object key in the translations database JSON file. To support description objects, riw needs some serialisation/deserialisation to/from strings.
riw can be installed globally or as a package dependency.
If installed globally, and if the CWD is within a package, and if that package has a local riw dependency, then running the global riw should punt to the package dependency.
We use this tool in CI (via module api, not cli). It would be nice if there was a way to disable the status bar output, since when not run in an interactive context, it floods the logs with filename output.
The file names in TODO-untranslated.json
are output as an absolute path. It should use the relative path from the app's root so that the file can be shared among developers.
Can we upgrade riw's version of babel to v7? Our app uses CRA which is now using the @babel
namespace. In order for our tooling to work properly, we have to override the babel-core version in our package.json
:
"resolutions": {
"**/babel-core": "7.0.0-bridge.0"
}
I believe this wouldn't be necessary if riw
upgraded babel-core
to @babel/core
.
Of course, doing so will probably require a major version bump...
~ yep, still here using riw
! makes my life so much easier.
During i18n, before (complete) l10n, it's often useful to use pseudolocales to simulate common features of languages other than English. For example, German strings are ~30% longer than English, which might affect layout.
riw should ship with some magic pseudolocales that derive algorithmically from the default locale. Possible pseudolocales include:
Some sequences in strings need special treatment, such as HTML tags and entities, and arguments in braces.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.