Git Product home page Git Product logo

Comments (7)

sgalal avatar sgalal commented on May 24, 2024 1

This will work:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/data.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/data.cn2t.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/data.t2cn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/bundle-browser.min.js"></script>

<div id="testingOpenCC" lang="zh-HK">
  <span>轉換整個頁面</span>
</div>
const converter = OpenCC.Converter({ from: 'hk', to: 'cn' });
const rootNode = document.documentElement;
const HTMLConvertHandler = OpenCC.HTMLConverter(converter, rootNode, 'zh-HK', 'zh-CN');

document.addEventListener('DOMContentLoaded', () => {
  HTMLConvertHandler.convert();
});

from opencc-js.

hugolpz avatar hugolpz commented on May 24, 2024 1

I think the readme is better now and suits the newbies' need requested above : we can indeed copy-paste and convert a page or section of page. This issue can be closed. 👍🏼

Scope limit could be better stated depending on the limits you want to fix.
Being able to convert string and save value on demand would expand possible usages.

from opencc-js.

sgalal avatar sgalal commented on May 24, 2024

I have updated the API. Now there is no async any more. Would you please see if this would be easier?

from opencc-js.

hugolpz avatar hugolpz commented on May 24, 2024

Hello Sgalal, thanks for the quick reply and REAME.md rewrite : ).
If I understand you still are actively developing & testing it, so may I give some feedbacks ?

  • I tested again on this pad, I wasn't able to make it works on client side.
    • Seems <script src="https://cdn.jsdelivr.net/npm/[email protected]/data.min.js"></script> drops an error. If I include this file twice, I get two errors, etc.
    • you can use the jsfiddle to test around or share working code.
  • On the readme, we can do shorter. Just sent you PR #11 .
  • Switching between { from: 'hk', to: 'cn' } and 'zh-HK', 'zh-CN' is confusing : where to use which ? It adds complexity. You may consider adopting one single localization system all around.

from opencc-js.

sgalal avatar sgalal commented on May 24, 2024

{ from: 'hk', to: 'cn' } affects the OpenCC conversion, while 'zh-HK', 'zh-CN' affects the lang attribute of HTML tags

Both are necessary because we can have multiple combinations like:

  • { from: 'tw', to: 'cn' } + 'zh-TW', 'zh-CN'
  • { from: 'twp', to: 'cn' } + 'zh-TW', 'zh-CN'
  • { from: 'tw', to: 'cn' } + 'cmn-TW', 'cmn-CN'
  • { from: 'twp', to: 'cn' } + 'cmn-TW', 'cmn-CN'
  • { from: 'tw', to: 'cn' } + 'nan-TW', 'nan-CN'
  • { from: 'twp', to: 'cn' } + 'nan-TW', 'nan-CN'
  • { from: 'tw', to: 'cn' } + 'nan-Hant-TW', 'nan-Hans-CN'
  • ...

from opencc-js.

hugolpz avatar hugolpz commented on May 24, 2024

I see that one feeds into OpenCC javascript, the other into html attribute lang.

Not sure, but seems...

  • JS localisation parameters : defines the direction + default or is p (cn: 自行车/自行車 -> tw: 脚踏车/腳踏車).
    • range of accepted values: limited (see #Basic_usage)
  • HTML attribute lang : identifies targets, optionally announced a language.
    • range of accepted values : string (is open). Recommended languages codes (IETF languages tags).

I was unable to make sections 2, 3, 4 works. See fiddle.

PS: I solved my main issue thanks to lang="*". Report above to offer some feedbacks and newbies can use OpenCC quickly 🥇

from opencc-js.

sgalal avatar sgalal commented on May 24, 2024

I was unable to make sections 2, 3, 4 works. See fiddle.

The usage is modified (see README)

from opencc-js.

Related Issues (10)

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.