Skip to content

Instantly share code, notes, and snippets.

@ZoolWay
Last active July 7, 2017 13:44
Show Gist options
  • Save ZoolWay/cb945f08daa0d53e89d34512a79a38e6 to your computer and use it in GitHub Desktop.
Save ZoolWay/cb945f08daa0d53e89d34512a79a38e6 to your computer and use it in GitHub Desktop.
Aurelia I18N update-value
<template>
<require from="my-comp"></require>
<h1>Aurelia I18N update-value</h1>
<my-comp title="simple"></my-comp>
<p>${'client:title' & t}</p>
</template>
import { observable } from 'aurelia-framework'
export class App {
modelB = { title: 'inner-compose' };
areaContainer = null;
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app="main">
<h1>Loading...</h1>
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script>
<script>
require(['aurelia-bootstrapper']);
</script>
</body>
</html>
{
"title": "Translated-Title",
"text": "Translated-Text"
}
//import 'https://unpkg.com/aurelia-i18n@1.6.1'
import 'https://unpkg.com/i18next@8.4.2/dist/es/index'
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.plugin('https://unpkg.com/aurelia-i18n@1.6.1/dist/aurelia-i18n', (instance) => {
let aliases = ['t', 'i18n'];
TCustomAttribute.configureAliases(aliases);
return instance.setup({
lng: 'en',
attributes: aliases,
ns: ['client'],
defaultNS: 'client',
debug: false
});
})
;
aurelia.start().then(() => aurelia.setRoot());
}
<template>
<div style="font-family:Lucida Console Regular; padding: 1em; background: silver;">
title: '${title}'
</div>
</template>
import { bindable } from 'aurelia-framework'
export class MyComp {
@bindable title = null;
activate(model) {
if ((model) && (model.title)) {
this.title = model.title;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment