-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
2,627 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export default { | ||
time: { | ||
hhmmss: { | ||
hour: 'numeric', | ||
minute: 'numeric', | ||
second: 'numeric', | ||
}, | ||
}, | ||
date: { | ||
hhmmss: { | ||
hour: 'numeric', | ||
minute: 'numeric', | ||
second: 'numeric', | ||
}, | ||
}, | ||
number: { | ||
compact: { | ||
notation: 'compact', | ||
}, | ||
EUR: { | ||
style: 'currency', | ||
currency: 'EUR', | ||
}, | ||
USD: { | ||
style: 'currency', | ||
currency: 'USD', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Route from '@ember/routing/route'; | ||
import { service } from '@ember/service'; | ||
|
||
export default class ApplicationRoute extends Route { | ||
@service intl; | ||
|
||
async beforeModel() { | ||
const locale = 'en-gb'; | ||
|
||
// Path to fingerprinted asset map is dealt with at build time by broccoli-asset-rev | ||
const map = await load('/assets/assetMap.json'); | ||
|
||
// Dynamic path to translation file, broccoli-asset-rev can't deal with this, | ||
// hence the need to look up the real (fingerprinted) path in the asset map. | ||
const path = `translations/${locale}.json`; | ||
const fingerprintedPath = map.assets[path]; | ||
|
||
const translations = await load(fingerprintedPath); | ||
|
||
await wait(500); | ||
|
||
this.intl.addTranslations(locale, translations); | ||
|
||
this.intl.setLocale([locale]); | ||
} | ||
} | ||
|
||
function load(url) { | ||
return fetch(url).then((response) => response.json()); | ||
} | ||
|
||
function wait(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Loading... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
{{page-title "Example"}} | ||
|
||
{{! The following component displays Ember's default welcome message. }} | ||
<WelcomePage /> | ||
{{! Feel free to remove this! }} | ||
|
||
{{outlet}} | ||
Translated string: {{t "greeting"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* jshint node:true */ | ||
|
||
module.exports = function (/* environment */) { | ||
return { | ||
/** | ||
* Merges the fallback locale's translations into all other locales as a | ||
* build-time fallback strategy. | ||
* | ||
* This will **not** prevent missing translation warnings or errors from occurring. | ||
* It's meant as safety net when warnings are enabled. | ||
* When enabled along with `errorOnMissingTranslations` any fallback attempts will result in an error. | ||
* | ||
* @property fallbackLocale | ||
* @type {String?} | ||
* @default "null" | ||
*/ | ||
fallbackLocale: null, | ||
|
||
/** | ||
* Path where translations are stored. This is relative to the project root. | ||
* For example, if your translations are an npm dependency, set this to: | ||
*`'./node_modules/path/to/translations'` | ||
* | ||
* @property inputPath | ||
* @type {String} | ||
* @default "'translations'" | ||
*/ | ||
inputPath: 'translations', | ||
|
||
/** | ||
* Prevents the translations from being bundled with the application code. | ||
* This enables asynchronously loading the translations for the active locale | ||
* by fetching them from the asset folder of the build. | ||
* | ||
* See: https://ember-intl.github.io/ember-intl/docs/guide/asynchronously-loading-translations | ||
* | ||
* @property publicOnly | ||
* @type {Boolean} | ||
* @default "false" | ||
*/ | ||
publicOnly: true, | ||
|
||
/** | ||
* Add the subdirectories of the translations as a namespace for all keys. | ||
* | ||
* @property wrapTranslationsWithNamespace | ||
* @type {Boolean} | ||
* @default "false" | ||
*/ | ||
wrapTranslationsWithNamespace: false, | ||
|
||
/** | ||
* Cause a build error if ICU argument mismatches are detected between translations | ||
* with the same key across all locales. | ||
* | ||
* @property errorOnNamedArgumentMismatch | ||
* @type {Boolean} | ||
* @default "false" | ||
*/ | ||
errorOnNamedArgumentMismatch: false, | ||
|
||
/** | ||
* Cause a build error if missing translations are detected. | ||
* | ||
* See https://ember-intl.github.io/ember-intl/docs/guide/missing-translations#throwing-a-build-error-on-missing-when-required-translations | ||
* | ||
* @property errorOnMissingTranslations | ||
* @type {Boolean} | ||
* @default "false" | ||
*/ | ||
errorOnMissingTranslations: false, | ||
|
||
/** | ||
* Removes empty translations from the build output. | ||
* | ||
* @property stripEmptyTranslations | ||
* @type {Boolean} | ||
* @default "false" | ||
*/ | ||
stripEmptyTranslations: false, | ||
|
||
/** | ||
* A function that is called whenever any translation key, from any locale, is missing at build time. | ||
* | ||
* See https://ember-intl.github.io/ember-intl/docs/guide/missing-translations#requiring-translations | ||
* | ||
* @property requiresTranslation | ||
* @type {Function} | ||
* @default "function(key,locale) { return true }" | ||
*/ | ||
requiresTranslation(/* key, locale */) { | ||
return true; | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
'use strict'; | ||
|
||
const EmberApp = require('ember-cli/lib/broccoli/ember-app'); | ||
const { Webpack } = require('@embroider/webpack'); | ||
const exampleAssetHost = 'http://localhost:4211'; | ||
const embroiderBuild = false; | ||
|
||
module.exports = function (defaults) { | ||
const app = new EmberApp(defaults, { | ||
// Add options here | ||
}); | ||
if (embroiderBuild) { | ||
module.exports = function (defaults) { | ||
const app = new EmberApp(defaults, {}); | ||
|
||
return app.toTree(); | ||
}; | ||
return require('@embroider/compat').compatBuild(app, Webpack); | ||
}; | ||
} else { | ||
module.exports = function (defaults) { | ||
const app = new EmberApp(defaults, { | ||
fingerprint: { | ||
enabled: true, | ||
exclude: ['testem.js'], | ||
extensions: ['js', 'json', 'css'], | ||
prepend: `${exampleAssetHost}/`, | ||
generateAssetMap: true, | ||
fingerprintAssetMap: true, | ||
}, | ||
}); | ||
|
||
return app.toTree(); | ||
}; | ||
} |
Oops, something went wrong.