Code Monkey home page Code Monkey logo

voerka-i18n's Introduction

适用于Javascript/Vue/React/ReactNative的国际化解决方案

官方网站

基于javascript的国际化方案很多,比较有名的有fbti18nextreact-i18nextvue-i18nreact-intl等等,每一种解决方案均有大量的用户。为什么还要再造一个轮子?好吧,再造轮子的理由不外乎不满足于现有方案,总想着现有方案的种种不足之处,然后就撸起袖子想造一个轮子。

那么到底是对现有解决方案有什么不满?最主要有三点:

  • 大部份均为要翻译的文本信息指定一个key,然后在源码文件中使用形如$t("message.login")之类的方式,然后在翻译时将之转换成最终的文本信息。此方式最大的问题是,在源码中必须人为地指定每一个key,在中文语境中,想为每一句中文均配套想一句符合语义的英文key是比较麻烦的,也很不直观不符合直觉。我希望在源文件中就直接使用中文,如t("中华人民共和国**"),然后国际化框架应该能自动处理后续的一系列麻烦。

  • 要能够比较友好地支持多库多包monorepo场景下的国际化协作,当主程序切换语言时,其他包或库也可以自动切换,并且在开发上每个包或库均可以独立地进行开发,集成到主程序时能无缝集成。这点在现有方案上没有找到比较理想的解决方案。

  • 大部份国际化框架均将中文视为二等公民,大部份情况下您应该采用英文作为第一语言,虽然这不是太大的问题,但是既然要再造一个轮子,为什么不将中文提升到一等公民呢。

    基于此就开始打造VoerkaI18n国际化多语言解决方案,主要特性包括:

  • 全面工程化解决方案,提供初始化、提取文本、自动翻译、编译等工具链支持。

  • 符合直觉,不需要手动定义文本Key映射。

  • 强大的插值变量格式化器机制,可以扩展出强大的多语言特性。

  • 支持babel插件自动导入t翻译函数。

  • 支持nodejs、浏览器(vue/react/solid)等、React Native等任意JS场景

  • 采用工具链运行时分开设计,发布时只需要集成很小的运行时。

  • 高度可扩展的复数货币数字等常用的多语言处理机制。

  • 翻译过程内,提取文本可以自动进行同步,并保留已翻译的内容。

  • 可以动态在线添加支持的语言

  • 支持发布后的在线打语言包补丁,修复翻译错误

  • 支持调用在线自动翻译对提取文本进行翻译。

  • 核心运行时@voerkai18n/runtime超过90%的测试覆盖率

开源推荐:

voerka-i18n's People

Contributors

zhangfisher avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.