Comments (6)
yeah tough call.. ideally we try to stay away from english etc but obviously that's not alway possible haha. I guess each component just needs to expose maybe an object containing the strings uses so they can be swapped, or we can try to get everyone using something like https://github.com/component/t, tough call. As long as they can easily be replaced then the application can handle the rest
from component.
staying library-agnostic would be great. we atm use gettext for easy collaboration with translation bureaus and sticking to an approved standard.
what i do now:
- leave strings out of the template
- pass a translation fn to the component
- fill in text through dom traversal and calls to that fn
this works with gettext and t. you alao get the benefit of having all translations take place in one code block.
is dom traversal the preferred way of doing this anyway, or will sth like mustache be integrated?
from component.
var $ = require('jquery');
var clazz = require('clazz');
var ee = require('events').EventEmitter;
var bind = require('bind');
function Card(pattern, t) {
clazz.base(this);
if (!t) t = function(s) { return s; };
var dom = this.dom = $(require('./template'));
dom.find('a').click(function(e) { e.preventDefault(); });
dom.find('.patternchart') .click(bind(this, this.emit, 'open', pattern));
dom.find('.watch') .click(bind(this, this.emit, 'watch', pattern));
dom.find('.products') .click(bind(this, this.emit, 'products', pattern));
dom.find('.details') .click(bind(this, this.emit, 'open', pattern));
dom.find('.category') .text( pattern.breakout? t('Ausgeborchen') : t('Ausgebildet') );
dom.find('.type') .text( t(pattern.type) );
dom.find('.headline part').text( t('auf') );
dom.find('.instrument') .text( t(pattern.instrument) );
dom.find('.watch') .text( t('Beobachten') );
dom.find('.products') .text( t('Produkte') );
dom.find('.details') .text( t('Details') );
};
clazz.inherit(Card, ee);
Card.prototype.render = function() {
return this.dom;
}
module.exports = Card;
from component.
there wont be anything integrated, probably best that we just provide some option(s) per component. Maybe we just do stuff like:
exports.strings = {
category: 'Category',
...
}
and reference those. There wont be mustache or anything built in but I wrote https://github.com/visionmedia/minstache to have super light-weight stand-alone view functions that we can compile beforehand
from component.
ok, that looks good too.
from component.
exports.strings
won't work when there is data from an API that is to be translated. If a component e.g. should print a color's name, like Your chosen background color is black
it needs to translate that on the fly.
3 possibilities:
- assign the whole translation object to exports.strings:
comp.strings = translations['en'] || clone(translations['en'])
- translate strings in the api response:
res.color = t(res.color)
- let your api do the translation
With the passed t-function that is already covered.
from component.
Related Issues (20)
- Can I use non-component based libraries? HOT 4
- component {fork,unfork} <component> HOT 2
- ComponentJS vs JSPM + SystemJS HOT 1
- Can't use Component modules with a RequireJS environment HOT 12
- Private Repo doesn't seem to be working HOT 17
- Getting Uncaught Error: failed to require template HOT 11
- need auth for travis to avoid github rate limit and failed build status
- On chrome debug points off by two lines for --dev builds HOT 2
- Getting Failed to Require message HOT 3
- component.github.io shows no results HOT 1
- fatal : no remote found for dependency '....' HOT 20
- fatal : Error downloading "github//component/[email protected]". Got status code "404" HOT 5
- getting component module to be called with --harmony HOT 4
- fatal : no remote found for dependency... HOT 2
- Follow the chain of paths for remote dependencies HOT 4
- announce "this project is not maintained anymore" HOT 8
- How to install dependencies to a particular folder? HOT 2
- How can a project depend on a github repository that doesn't have a componser.json HOT 2
- Clean up the maintainers list? HOT 2
- Cant require node_modules when componentjs is installed? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from component.