Comments (7)
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.
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.
I have updated the API. Now there is no async
any more. Would you please see if this would be easier?
from opencc-js.
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.
- Seems
- 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.
{ 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.
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.
I was unable to make sections 2, 3, 4 works. See fiddle.
The usage is modified (see README)
from opencc-js.
Related Issues (10)
- Review new documentation section API HOT 2
- >=v1.0.0 take too much time to translate web pages
- es6 imports HOT 10
- `.HTMLConverter`: convert also placeholder and aria-label attributes. HOT 2
- 效能提升的方式 HOT 2
- 使用window或globalThis声明OpenCCJSData变量 HOT 1
- 请问能否更新一下数据源呢 HOT 4
- whether dynamic translation is possible HOT 1
- HTML 转换时手动跳过部分元素的实现 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencc-js.