Currently, i18n and l10n is not easy and mature for web applications or sites.
It can cause a lot efforts for both server side and frontend developers.
And still it can be a big challenge .
I would like to suggest cerntain ways to solve this problem generally by browsers.
my suggestions are simple.
HTML part
define i18n resource with tag
it can define:
orignized folders.
<i18n url="./i18n"/>
orginized resources like images, strings, etc.
`
the browsers should be able to enumerate how many languages are supported by this application/site or it can be described like this:
<i18n locales=["en", "zh", "fr", "jp"]></i18n>
use resource locally with tag.
it can be used like this:
Hello world!
你好, 世界!
add a tag` to define i18n resources for the web applications/sites.
### JS API part
1. add `i18n` and `l10n` objects
2. `i18n` provides apis:
`i18n`.`hasLocale`
which returns `["en", "zh", "fr", "jp"']`
`i18n`.`getLocale`
returns a `l10n` object, `null` if not supported
`i18n`.`setLocale`
set new locale for current web application/site
3. `l10n` provides apis:
`l10n`.`format`
formats a string with parameters
`l10n`.`get`
get an object by an id or an indexable string
```
l10n.get("image-id", "image")
l10n.format("hello :name", {name: l10n.get("name-id", "string")});
```
### Browser side
Browsers should be able to fetch all i18n resource indicated by the tags on the first load and every update.
## Feedback
Introduction
Currently, i18n and l10n is not easy and mature for web applications or sites. It can cause a lot efforts for both server side and frontend developers. And still it can be a big challenge .
I would like to suggest cerntain ways to solve this problem generally by browsers.
my suggestions are simple.
HTML part
define i18n resource with tag
it can define:
orignized folders.
<i18n url="./i18n"/>
orginized resources like images, strings, etc. `
the browsers should be able to enumerate how many languages are supported by this application/site or it can be described like this:
use resource locally with tag.
it can be used like this:
Hello world!你好, 世界!
add a tag` to define i18n resources for the web applications/sites.
### JS API part
1. add `i18n` and `l10n` objects
2. `i18n` provides apis:
`i18n`.`hasLocale`
which returns `["en", "zh", "fr", "jp"']`
`i18n`.`getLocale`
returns a `l10n` object, `null` if not supported
`i18n`.`setLocale`
set new locale for current web application/site
3. `l10n` provides apis:
`l10n`.`format`
formats a string with parameters
`l10n`.`get`
get an object by an id or an indexable string
```
l10n.get("image-id", "image")
l10n.format("hello :name", {name: l10n.get("name-id", "string")});
```
### Browser side
Browsers should be able to fetch all i18n resource indicated by the tags on the first load and every update.
## Feedback