-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Globalize #54
base: master
Are you sure you want to change the base?
Conversation
35d35f7
to
f2d4819
Compare
@@ -2,6 +2,7 @@ | |||
|
|||
'use strict'; | |||
|
|||
var GLB = require('strong-globalize'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camel case: glb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
f51a5c0
to
0063b05
Compare
@@ -0,0 +1,31 @@ | |||
{ | |||
"all1": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's one of the GPB issues. For es, fr, and pt, this string is translated to empty most likely due to the double curly braces. The issue has been reported to the GPB team.
#54 (comment) is unresolved (mentioning here because it is not displayed because of code updates) |
re: space is allowed in keys in json (any string is): // fr/messages.json
which could be used like: I'm not sure how difficult to achieve this would be, but I'd like you to consider it more carefully. Strengths are:
There might be some down sides. What do other users of the globalize package do? Have you done some checking for blogs/design advice? My experience may be biased by GNU gettext, in that I've worked on code that uses GNU internationalization, and other than seeing I may be biased, but translators are not going to see our source, we have to maintain and debug it all the time, we need to put effort into making it easier for us. Also, if its hard for us, we'll get it wrong, and then the best translatio won't help, because we will have bugs in our source. |
49fcb95
to
c474262
Compare
This is an example of what our code will look like once globalized. More than an example, this is the globalized strong-deploy. Looks pretty good to me, minimally intrusive. See https://github.com/strongloop/strong-globalize/blob/refactor-a/README.md for more information on the toolset. Also, note that once the code is converted to use |
.replace(/%MAIN%/g, $0) | ||
.trim(); | ||
|
||
var USAGE = glb.t('sl-deploy.txt') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this scenario it totally makes sense, but there's something weird to me about how it completely abstracts away the file opening and reading while still clearly operating on a specified file. I would expect there to have been a path resolver wrapped around the path string instead. I imagine it to look like this:
var USAGE = fs.readFileSync(glb.resolve('./sl-deploy.txt'), 'utf-8')
.replace(/%MAIN%/g, $0)
.trim();
If the logical resource is simply a string and the fact that it is in a file is an implementation detail, then I would expect the name to be something like 'USAGE'
or something.
I expected strong-globalize to provide an API for operating on Strings, not replicate/wrap all the existing API's that current use Strings.. var t = require('strong-globalize').translate;
var f = require('strong-globalize').format;
console.log(t('Strings for life!'));
console.error(f('%j: %s', new Date(), process.argv[2])); |
Also, all the followings work too: var g = require('strong-globalize');
console.log(g.t('Strings for life!'));
g.log('Strings for life!');
console.error(g.t('%j: %s', new Date(), process.argv[2]));
console.error(g.t('%j: %s', g.d(new Date()), process.argv[2]));
console.error(g.t('%s: %s', g.d(new Date()), process.argv[2]));
g.error('%j: %s', new Date(), process.argv[2]);
g.error('%j: %s', g.d(new Date()), process.argv[2]);
g.error('%s: %s', g.d(new Date()), process.argv[2]); Now that i've dog-fooded and globalized strong-deploy, strong-pm, strong-build, strong-mesh-models, strong-service-install and cli.js of strong-arc, i personally like the following because the key strokes i hit is least (and, it was even fun particularly because messages.json is auto-created and machine-translated to 9 languages (Russian is coming soon) in seconds). I don't mind writing code like this from the beginning: var g = require('strong-globalize');
g.log('Strings for life!');
g.error('%s: %s', g.d(new Date()), process.argv[2]); |
@sl-node test please |
@sl-node test please |
); | ||
g.error( | ||
'Unable to detect service name, {{package.json}} ' + | ||
'has no "name" property.\n' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name has to be protected
e8ae74e
to
7ce5d6b
Compare
This requires strongloop/strong-globalize#5 |
@sl-node test please |
1 similar comment
@sl-node test please |
LGTM, but we can't merge until strong-globalize is published. |
connected to strongloop-internal/scrum-nodeops#1157