diff --git a/fluent-web/.gitignore b/fluent-web/.gitignore deleted file mode 100644 index 78a9a5f07..000000000 --- a/fluent-web/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -fluent-web.js -compat.js diff --git a/fluent-web/CHANGELOG.md b/fluent-web/CHANGELOG.md deleted file mode 100644 index e60b5b0c9..000000000 --- a/fluent-web/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -# Changelog - -## Unreleased - - - Drop support for IE and old evergreen browsers. (#133) - - Currently supported are: Firefox 52+, Chrome 55+, Edge 15+, Safari 10.1+, - iOS Safari 10.3+ and node 8.9+. - -## fluent-web 0.0.1 - - - The initial release. diff --git a/fluent-web/README.md b/fluent-web/README.md deleted file mode 100644 index 9c1dcff39..000000000 --- a/fluent-web/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# fluent-web - -`fluent-web` is a runtime polyfill that binds `Fluent` and `FluentDOM` into -a vanilla Web platform (HTML, DOM, JS). - -## Installation - -`fluent-web` provides a glue code that is executed at runtime to construct -`DOMLocalization`, bind it to `document.l10n`, perform initial document -translation and set the event listeners and MutationObserver. - -The result `fluent-web.js` file should be included in the HTML file -and any code executing after it will have access to the FluentWeb API. - - -## How to use - -The primary access point is the `document.l10n` object of class -`DOMLocalization`. It is already constructed based on the resources -linked from the document and localized into languages negotiated based -on the available languages from the `` tag and languages -requested via `navigator.languages`. - -```html - - - - - - - - - -

- - -``` - -```javascript - -function showMessage() { - let msg = await document.l10n.formatValue('confirm-msg') - alert(msg); -} - -let h1 = document.querySelector('h1'); -document.l10n.setAttributes(h1, 'welcome', { user: 'Anna' }); -``` - -## Learn more - -Find out more about Project Fluent at [projectfluent.org][], including -documentation of the Fluent file format ([FTL][]), links to other packages and -implementations, and information about how to get involved. - - -[projectfluent.org]: http://projectfluent.org -[FTL]: http://projectfluent.org/fluent/guide/ diff --git a/fluent-web/bundle_config.js b/fluent-web/bundle_config.js deleted file mode 100644 index d180eb433..000000000 --- a/fluent-web/bundle_config.js +++ /dev/null @@ -1,12 +0,0 @@ -import bundleConfig from '../bundle_config'; -import nodeResolve from 'rollup-plugin-node-resolve'; - -export default Object.assign({}, bundleConfig, { - output: { - format: 'iife' - }, - context: 'this', - plugins: [ - nodeResolve(), - ] -}); diff --git a/fluent-web/compat_config.js b/fluent-web/compat_config.js deleted file mode 100644 index 5ee4b945f..000000000 --- a/fluent-web/compat_config.js +++ /dev/null @@ -1,11 +0,0 @@ -import compatConfig from '../compat_config'; -import nodeResolve from 'rollup-plugin-node-resolve'; -import babel from 'rollup-plugin-babel'; - -export default Object.assign({}, compatConfig, { - context: 'this', - plugins: [ - nodeResolve(), - ...compatConfig.plugins - ], -}); diff --git a/fluent-web/examples/localization/en-US/fluent-widget.ftl b/fluent-web/examples/localization/en-US/fluent-widget.ftl deleted file mode 100644 index b467addf1..000000000 --- a/fluent-web/examples/localization/en-US/fluent-widget.ftl +++ /dev/null @@ -1,4 +0,0 @@ -proceed-button = - .label = Do you want to proceed? - .action-ok = Yes - .action-cancel = No diff --git a/fluent-web/examples/localization/en-US/main.ftl b/fluent-web/examples/localization/en-US/main.ftl deleted file mode 100644 index e5a12c70c..000000000 --- a/fluent-web/examples/localization/en-US/main.ftl +++ /dev/null @@ -1,5 +0,0 @@ -hello-world = Hello, world! -sub-title = Fluent is awesome. -click-me = - .value = Click me! -alert-msg = This is a message that goes straight to JS. diff --git a/fluent-web/examples/localization/pl/fluent-widget.ftl b/fluent-web/examples/localization/pl/fluent-widget.ftl deleted file mode 100644 index 08962c447..000000000 --- a/fluent-web/examples/localization/pl/fluent-widget.ftl +++ /dev/null @@ -1,4 +0,0 @@ -proceed-button = - .label = Czy chcesz przejść dalej? - .action-ok = Tak - .action-cancel = Nie diff --git a/fluent-web/examples/localization/pl/main.ftl b/fluent-web/examples/localization/pl/main.ftl deleted file mode 100644 index 414be63ff..000000000 --- a/fluent-web/examples/localization/pl/main.ftl +++ /dev/null @@ -1,4 +0,0 @@ -hello-world = Witaj Świecie! -click-me = - .value = Naciśnij mnie! -alert-msg = Ta wiadomość idzie prosto do JS. diff --git a/fluent-web/examples/simple.html b/fluent-web/examples/simple.html deleted file mode 100644 index a3a4b0343..000000000 --- a/fluent-web/examples/simple.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - -

-

- - - - diff --git a/fluent-web/examples/webcomponent.html b/fluent-web/examples/webcomponent.html deleted file mode 100644 index 86ea1b9d3..000000000 --- a/fluent-web/examples/webcomponent.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/fluent-web/makefile b/fluent-web/makefile deleted file mode 100644 index 04318bd83..000000000 --- a/fluent-web/makefile +++ /dev/null @@ -1,28 +0,0 @@ -PACKAGE := fluent-web -GLOBAL := FluentWeb - -include ../common.mk - -build: $(PACKAGE).js compat.js - -$(PACKAGE).js: $(SOURCES) - @rollup $(CURDIR)/src/index.js \ - --config $(CURDIR)/bundle_config.js \ - --banner "/* $(PACKAGE)@$(VERSION) */" \ - --amd.id $(PACKAGE) \ - --name $(GLOBAL) \ - --output.file $@ - @echo -e " $(OK) $@ built" - -compat.js: $(SOURCES) - @rollup $(CURDIR)/src/index.js \ - --config $(CURDIR)/compat_config.js \ - --banner "/* $(PACKAGE)@$(VERSION) */" \ - --amd.id $(PACKAGE) \ - --name $(GLOBAL) \ - --output.file $@ - @echo -e " $(OK) $@ built" - -clean: - @rm -f $(PACKAGE).js compat.js - @echo -e " $(OK) clean" diff --git a/fluent-web/package.json b/fluent-web/package.json deleted file mode 100644 index 1877b32e3..000000000 --- a/fluent-web/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "fluent-web", - "version": "0.0.1", - "description": "Drop-in localization framework for HTML documents", - "repository": { - "type": "git", - "url": "https://github.com/projectfluent/fluent.js.git" - }, - "author": "Mozilla ", - "license": "Apache-2.0", - "contributors": [ - { - "name": "Zibi Braniecki", - "email": "zbraniecki@mozilla.com" - }, - { - "name": "Staś Małolepszy", - "email": "stas@mozilla.com" - } - ], - "directories": { - "lib": "./src" - }, - "main": "./fluent-web.js", - "module": "./src/index.js", - "keywords": [ - "localization", - "l10n", - "internationalization", - "i18n", - "locale", - "language", - "formatting", - "translate", - "translation", - "format" - ], - "engines": { - "node": ">=8.9.0" - }, - "dependencies": { - "fluent": "~0.4.0", - "fluent-langneg": "~0.1.0" - } -} diff --git a/fluent-web/src/index.js b/fluent-web/src/index.js deleted file mode 100644 index 7e602f2ec..000000000 --- a/fluent-web/src/index.js +++ /dev/null @@ -1,82 +0,0 @@ -/* eslint-env browser */ - -import { negotiateLanguages } from "fluent-langneg"; -import { MessageContext } from "fluent"; -import { DOMLocalization } from "../../fluent-dom/src/index"; - -function documentReady() { - const rs = document.readyState; - if (rs === "interactive" || rs === "completed") { - return Promise.resolve(); - } - - return new Promise( - resolve => document.addEventListener( - "readystatechange", resolve, { once: true } - ) - ); -} - -function getMeta(elem) { - return { - available: elem.querySelector('meta[name="availableLanguages"]') - .getAttribute("content") - .split(",").map(s => s.trim()), - default: elem.querySelector('meta[name="defaultLanguage"]') - .getAttribute("content"), - }; -} - -function getResourceLinks(elem) { - return Array.prototype.map.call( - elem.querySelectorAll('link[rel="localization"]'), - el => el.getAttribute("href") - ); -} - -async function fetchResource(locale, id) { - const url = id.replace("{locale}", locale); - const response = await fetch(url); - return response.text(); -} - -async function createContext(locale, resourceIds) { - const ctx = new MessageContext([locale]); - - // First fetch all resources - const resources = await Promise.all( - resourceIds.map(id => fetchResource(locale, id)) - ); - - // Then apply them preserving order - for (const resource of resources) { - ctx.addMessages(resource); - } - return ctx; -} - -const meta = getMeta(document.head); - -function* generateMessages(resourceIds) { - const locales = negotiateLanguages( - navigator.languages, - meta.available, - { - defaultLocale: meta.default - } - ); - for (const locale of locales) { - yield createContext(locale, resourceIds); - } -} - -const resourceIds = getResourceLinks(document.head); -document.l10n = new DOMLocalization( - window, resourceIds, generateMessages -); -window.addEventListener("languagechange", document.l10n); - -document.l10n.ready = documentReady().then(() => { - document.l10n.connectRoot(document.documentElement); - return document.l10n.translateRoots(); -}); diff --git a/fluent-web/test/noop_test.js b/fluent-web/test/noop_test.js deleted file mode 100644 index e69de29bb..000000000