Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n,l10n general solution proposal #161

Open
calidion opened this issue Jul 13, 2024 · 0 comments
Open

i18n,l10n general solution proposal #161

calidion opened this issue Jul 13, 2024 · 0 comments

Comments

@calidion
Copy link

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:

  1. orignized folders.
    <i18n url="./i18n"/>

  2. orginized resources like images, strings, etc.
    `

  3. 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<i18n> 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant