anticoders / meteor-i18n Goto Github PK
View Code? Open in Web Editor NEWSimplest internationalization package for Meteor
License: MIT License
Simplest internationalization package for Meteor
License: MIT License
Hi @apendua, thanks for your great work.
I'm hoping to compare a i18n value against a test value, but cannot get package to be imported as keeps saying. Error: Cannot find module 'meteor/anti:i18n'
.
Tests are being ran via npm run test:dev-chimp:
"test:dev-chimp": "chimp --ddp=http://localhost:3000 --path=tests --watch --chai --mocha"
Code when testing (been shortened):
import { assert } from 'chai';
import i18n from 'meteor/anti:i18n';
...
it('Correct page title', function() {
let title = browser.getTitle();
expect(title).to.equal(i18n("pages.settings.user.settings"))
});
...
Any help greatly appreciated :)
Just wanted to ask if this could be included into the package directly or is it better to create an own package for this?
based on navigator.language
Then the developer could just set this feature on/off with:
i18n.autoDetect = true/false (default false)
For the developer it could also mean, that the language string in the i18n.map method should be a standardized iso language string.
Hi,
I tried to make a 2 languages application (en & fr).
When I change the language to French, there's no problem, the display rerenders with French values, I can navigate throughout the application... Until I reload a page: when pressing F5
, the language preference is reset to default.
Great module.
Best regards.
PS: I'm using Iron Router.
Hi
Is it possible to use a fallback language instead of showMissing? So one could use a partial translation in one language, and english where it's missing?
I have debugged your code and I am not sure about this part :
i18n.setDefaultLanguage = function(language) {
i18n._default = 'language';
i18n._dep.changed();
};
I think it should be : i18n._default = language;
I am using "just-i18n" with "meteor-autoform" and I want my labels to be reactive when language changes. Assigning i18n('key')
to the labels defined in my "SimpleSchemas" did not help.
Isn't the global javascript function i18n()
supposed to be reactive ??
I tried wrapping i18n()
inside another global function trans()
which returns a callback for i18n()
and magically this fixed the problem. I don't know why this helped and if this is the correct way to do it ??!!
Here is my code:
// Translate reactively
transr = function(key) {
return function() {
return i18n(key);
};
};
Schema.user = new SimpleSchema({
email: {
type: String,
label: transr('email'),
regEx: SimpleSchema.RegEx.Email,
},
//...
});
P.S. I am new to reactive programming :)
Wanted to know if this works in offline mode using app cache?
For example, if I have a multi-paragraph message need to be translated, I'll have this in my i18n.js:
i18n.map('en', { great_text: '<p>paragraph 1</p><p>paragraph 2</p>' });
But then {{i18n "great_text"}} will escape html tags and display following to user:
<p>paragraph 1</p><p>paragraph 2</p>
Is it possible to disable html escaping and just insert raw html into page?
I'm coming to the i18n from .po
and .mo
files, so I'm not sure how to handle markup tags in this placeholder model.
I'd typically embed some simple HTML inside the translated string. For example get your <strong>toys</strong> here
. But with blaze, that doesn't work, the tag gets output. What's the best way to approach this with just-i18n?
PS> Thanks for an awesome piece of software, helping to make Meteor rock onwards. ๐
if(typeof template === string) gives the error 'string is not defined', should be 'string' i guess
how to call "i18n(label)" with params?
and could i change param from {$1}
to {$otherWords}
?
Hi,
I'm having trouble with this usage:
<head>
<title>{{i18n 'key'}}</title>
</head>
the browser does not change this to translated message; it keeps {{i18 'key'}}
as title. Is this bug or am I doing something wrong?
Cheers,
Khrone
https://github.com/comerc/lang
You can improve functionality.
just a thought for a little trick to share with the community or add as feature to your source.
maybe you'll share it on your README.md
In order to capitalize the first Character of any i18n string you can add your own little helper:
UI.registerHelper('I18n',function(string) { return i18n(string).charAt(0).toUpperCase() + i18n(string).slice(1); });
note the use of UPPERCASED I18n
instead of i18n
Hello and thank you for this package!
I was wondering if it was safe to use the triple brackets to render HTML strings like so:
# in a coffee file
i18n.map 'en_US', homepage:
title: '<span class="bold">Meteor is</span> awesome!'
# in a template
{{{i18n 'homepage.title'}}}
As the user can easily change the content of homepage.title, it is maybe in this case a more general question, is it safe to use the triple brackets in Meteor or should we avoid such practice?
What about adding a function to get the map ?
The use would be to check which languages are in the map.
Hi,
When I add empty key:
i18n.map('en', {
key: ""
});
with option i18n.showMissing(true);
the handlebars helper {{i18n 'key'}}
is returning the key not empty string. Same goes to the i18n
function. I think it's bug; and I just don't have time to write fix and make pull request on my own :)
Cheers
where and structure for i18n?
both or client or sever folder for this.
and the structures ????????????
both/i18n/en.i18n.json, ...kh.i18n.json
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.