Git Product home page Git Product logo

1ec5 / avim Goto Github PK

View Code? Open in Web Editor NEW
46.0 7.0 4.0 7.3 MB

Vietnamese input method extension (IME) for Firefox, Thunderbird, SeaMonkey, Komodo, etc. — bộ gõ tiếng Việt dành cho Firefox, Thunderbird, SeaMonkey, Komodo, …

Home Page: http://avim.1ec5.org/

License: MIT License

Python 12.00% JavaScript 84.68% CSS 1.42% HTML 1.89%
vietnamese avim firefox thunderbird komodo seamonkey ime input-method telex vni

avim's Introduction

AVIM for Firefox

AVIM is an extension for Firefox, Thunderbird, Komodo, and similar applications that functions as an input method editor for Vietnamese, allowing you to insert diacritical marks easily everywhere you can type. This extension, along with a basic Chrome extension of the same name, are based on the avim.js script by Hiếu Đặng. Read more about AVIM for Firefox.

Important: Firefox 57 is incompatible with AVIM due to the new WebExtensions feature that is replacing traditional extensions. AVIM cannot be updated to work in Firefox 57 until AVIM’s most basic functionality is possible in WebExtensions. Please subscribe to this issue and vote for any Bugzilla bug reports mentioned there. Thank you for your understanding.

AVIM là một phần mở rộng cung cấp bộ gõ tiếng Việt trong Firefox, Thunderbird, Komodo, và các chương trình tương tự, cho phép đặt dấu một cách dễ dàng ở bất cứ mọi nơi mà bạn có thể nhập văn bản. Phần mở rộng này, cũng như một tiện ích mở rộng cùng tên dành cho Chrome, đều dựa trên kịch bản avim.js của Đặng Trần Hiếu. Đọc thêm về AVIM cho Firefox.

Quan trọng: Firefox 57 không tương thích với AVIM vì tính năng WebExtensions mới thay thế phần mở rộng truyền thống. AVIM không thể được cập nhật để hoạt động trong Firefox 57 cho đến khi có thể thực hiện các chức năng cơ bản của AVIM bằng WebExtensions. Xin vui lòng theo dõi vấn đề này và bỏ phiếu cho các bản báo cáo lỗi tại Bugzilla được nhắc đến trong vấn đề đó. Chân thành cám ơn sự thông cảm của các bạn.

Installation

Visit Firefox Add-ons or Thunderbird Add-ons for the latest Mozilla-approved version of the extension.

Hãy truy cập phiên bản mới nhất tại Tiện ích Firefox hoặc Tiện ích Thunderbird, các bản này được Mozilla chấp nhận.

Building

Build Status

To package the code as an extension yourself, you can use the included build script, which requires Python 2.7. In a command line window, navigate to the avim/ directory and execute the following commands:

pip install -r requirements.txt
python build.py

Two installable archives, avim.xpi and avim-VERSION.xpi, should now reside in that directory.

Để gói lấy mã nguồn thành phần mở rộng, bạn có thể sử dụng script xây dựng, cần Python 2.7. Trong cửa sổ dòng lệnh, hãy duyệt tới thư mục avim/ và chạy lệnh sau:

pip install -r requirements.txt
python build.py

Hai gói cài đặt được, avim.xpiavim-PHIÊN_BẢN.xpi, sẽ nằm trong thư mục đó. Script xây dựng có vài tùy chọn, chẳng hạn để sản xuất một phiên bản soát lỗi có bộ phận đo thử.

Tests

The test harness requires SpiderMonkey, the command line interface to the JavaScript engine in Firefox:

  1. Download last night’s build: jsshell-platform.zip, where platform is your operating system. (The latest official release of SeaMonkey is ancient but should work also.)
  2. Go to the tests/ directory in your checkout of this project.
  3. Run /path/to/js -b -s test.js.

The tests/ directory also contains corpus.js, useful for testing AVIM against a wordlist, such as those maintained by the hunspell-vi project.

Translations

AVIM’s user interface is currently available in several languages. Please help translate AVIM into additional languages at BabelZilla Beta.

Giao diện của AVIM hiện có sẵn trong vài ngôn ngữ. Xin hãy giúp biên dịch AVIM ra thêm ngôn ngữ tại BabelZilla Beta.

Translation statistics for AVIM

License

AVIM is licensed under the MIT license.

AVIM được phát hành theo giấy phép MIT.

More information

For a detailed documentation and a feature comparison against other Vietnamese IMEs, see AVIM’s official website and project wiki.

Xem tài liệu đầy đủ và bảng các tính năng so với các bộ gõ tiếng Việt khác tại trang chủ AVIMwiki của dự án.

avim's People

Contributors

1ec5 avatar defman21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

avim's Issues

Too many undo levels

AVIM registers too many undo levels (about one per letter). Undo transactions were coalesced in 20080224.139, but the undo levels came back in 20080728.325 with the custom SpliceTxn transaction object. To get coalescing working again, SpliceTxn needs to implement the merge() method on Components.interfaces.nsITransaction.

Place diacritics on nearest valid syllable (multisyllabic loan words or VNY2K)

AVIM should only consider the nearest valid syllable when adding diacritics. That would make it much easier to type multisyllabic loan words like “kilômét” (kilo^me't) as well as Vietnam2000Vietnamese2020.

Perhaps it needs to be a preference (that could replace the existing spelling enforcement preference), because spelling enforcement would be severely weakened. Should adding + to “chỗo” result in “chỗơ” or “chỡo” or “chõo+”? We need to think about these issues more deeply.

Convert test harness into a series of unit tests

Debug builds of AVIM have a built-in test harness that automatically types and verifies all the words in an input file (such as the FVDP corpus) in various configurations. The test harness made for an interesting demonstration years ago, but these days it makes much more sense to run unit tests on the command line, without Firefox running.

Before we can get conventional unit tests up and running, we should factor out the core input method engine #20 to remove the dependency on the DOM. The unit tests should be run via Spidermonkey or, failing that, some other JavaScript command line tool like node.

Explicit preference to ignore URL fields

AVIM ignores the URL bar and any <input type="url"> fields when urlbar is in the blacklist. But the blacklist is intended for matching element IDs, not element types, and it’s a very advanced preference. Instead, there should be a dedicated preference for ignoring URL fields, like the password preference. When migrating users to the new preference format, urlbar should be removed from the blacklist and the new preference should be set.

Support Electrolysis (Firefox)

Update: This bug has been repurposed for Firefox Electrolysis support. Fennec Electrolysis support is now covered by #86.

AVIM supported the very first versions of Fennec (now Firefox Mobile), but then Fennec 4.0 adopted an IPC architecture called Electrolysis that severely restricts access to page content from chrome. Mozilla also tried to move desktop Firefox in that direction at one point.

Although such architectures are generally seen as optimal for extensions like AVIM that primarily interface with page DOM, AVIM relies on anonymous DOM nodes, internal command handlers, and various other features that would never be available to the page context. So simply shoving AVIM into a page script would break most of AVIM’s unique feature set and expose it to conflicts with in-page IMEs like avim.js.

I’m not sure what the solution is, but we’ve continually gotten requests to bring back Firefox Mobile support, because unfortunately people found out about it at about the time Electrolysis landed.

Bring back per-character undo/redo in Komodo

The original, custom support for Scintilla in Komodo IDE/Edit was laid alongside plain text support: every call to modify the DOM was special-cased. But then Scintilla support was migrated to the TextControlProxy model, which operates on a line-by-line basis. Unfortunately, that makes undo/redo really annoying, especially when performing multicursor edits.

TextControlProxy operates on a line-by-line basis because most of its subclasses don’t have fine-grained access to the text control. But we have superb access to Scintilla, so we should do better.

Suggest diacritics using Accentuate.us API

There’s already an Accentuate.us extension that automatically adds diacritics to text as you type. But users may find that approach too aggressive or (depending on writing style and content) not quite accurate enough. AVIM could optionally integrate with Accentuate.us to provide suggestions for diacritics to insert, similar to what Google Input Tools does for Vietnamese.

AVIM doesn’t work in Zoho Docs

AVIM used to work in Zoho Docs except for Zoho Show. It doesn’t work at all in Zoho Docs anymore.

Zoho Show uses #texteditable[contenteditable] but does something tricky behind the scenes. ShapeEvent.text and ShapeEditor.text.editor look like good starting points for a proxy.

Automatically normalize homographs of Đ

The uppercase eth (Ð) and uppercase retroflex D (Ɖ) both look identical to the Vietnamese Đ. The eth used to be prevalent on Vietnamese-language websites, and it still crops up once in a while due to copy-paste. AVIM should recognize and normalize both characters to Đ.

GitHub Pages

AVIM’s existing site is a pain to maintain and localize. I experimented with building a new site atop Movable Type; it looked pretty but was similarly hard to maintain. Now that AVIM has moved to GitHub, it’s only natural that we adopt GitHub Pages. Hopefully we can still get the installation workflow right.

I don’t know if the “Test Drive” page can be hosted on GitHub Pages, especially with the embedded Ace editor and Silverlight applet. Perhaps it needs to remain a static HTML page.

Stop using early returns?

In an effort to tame the original AVIM input engine code long ago, I replaced many complex, multiply-nested conditionals with opportunistic use of early returns. This approach is more useful in some parts of the code, like ckspell(), than in others. By a back-of-the-napkin estimate, converting avim.js to conform to structured programming style would save almost 2 kB. I wonder if we could refactor some of this code to eliminate the large branches that incentivize early returns.

Convert extension icon to SVG

The extension icon looks goregous now, but it can probably be represented quite faithfully in SVG while taking up much less space.

VIQR-specific preferences

We should remove the dedicated VIQR* input method and let you choose between + and * and between ' and / for the VIQR input method. Per–input method preferences would also allow us to support an alternate version of Telex (entirely different dead keys) that’s in use in a few places.

Bring back Google Docs support

Google Docs was supported off and on around 2011 with a very fragile solution that groped around to determine the context and mimicked copy-paste to modify the text. It broke because Google kept changing the DOM. Meanwhile, they added Virtual Keyboard to the site, so users stopped pleading for Google Docs support in AVIM. Nonetheless, users expect AVIM to work everywhere within the browser, and Google Docs should be no exception. In principle, the implementation could be made to work again; we just need to figure out where things have moved.

AVIM breaks undo/redo in Ace

After adding diacritics in an Ace editor, the undo/redo stacks get garbled. Often, the right insertions are redone, but in the wrong order.

Per-site preferences

Optionally remember on/off state per-site, using FUEL or the Content Preferences service. Maybe limit this feature to bookmarks (FUEL), since the UI to set the preferences would be easier to figure out. Perhaps we could model the UI after Firebug’s panel enabling preferences.

I don’t think it’s as important to remember input methods per site, because most users use only one input method regularly, while they might type in another language and have no use for AVIM on certain sites.

Another possibility would be to automatically turn AVIM on and off based on a page’s HTML lang attribute. That would be consistent with Firefox’s spell checking feature.

Panel label always says “AVIM” in Firefox 3

The stylesheet uses the :-moz-any() pseudoclass extensively, including for the rule that sets text-decoration on the panel and toolbar button labels. Firefox 2–3 don’t support this pseudoclass, so the cross-out effect doesn’t work, making it difficult to tell when AVIM is turned on.

Adopt Transifex for localization

Localization has always been done in BabelZilla. Its benefits include tight integration with extension development workflows and a community of translators who specialize in the Mozilla ecosystem. However, its interface is quite painful to use, and publishing localizations is a manual affair.

We should move localization to Transifex, which has good GitHub integration and a top-notch interface. It supports Mozilla DTD and .properties files. We can also convert amo.dtd into a Markdown file for easier translation. My only concerns are that most translators there have little to no familiarity with Mozilla-based applications, and that some rely too heavily on machine translation.

Nuke sandboxes

AVIM creates tons of sandboxes every time a key is pressed. As far as I know, nothing hangs onto these sandboxes, but it might be a good idea to more thoroughly clean up by nuking them all at the end of the key event handlers.

See mozilla/addon-sdk#479.

Make AVIM restartless

AVIM should be a restartless extension.

This task primarily consists of converting the complex web of overlays into functions that programmatically build AVIM’s UI. We’re partway there with the new toolbar.

Upon installation, bootstrap.js would manually build the UI in every existing window and register for new windows using FUEL/STEEL.

Upon uninstallation, it would delete window.avim from every existing window, remove UI, and remove the new window listener. The XPCOM component probably doesn’t need any changes.

Need an easier keyboard shortcut to toggle AVIM

As Phan Tùng Quân notes, Ctrl+Alt+V is a rather inconvenient shortcut for toggling AVIM, something that happens very often. (On the Mac, ⌥⌘V is a bit more comfortable.) AVIM used Ctrl+Shift+V back in 2008 (from version 20080224.59 to 20080224.87), but users complained that it conflicted with AdBlock Plus, leaving them with no shortcut for AVIM at all. I don’t think Mozilla would be very happy if AVIM forcefully remapped AdBlock Plus’s shortcut, so we should find something else that is both easy to reach and logical.

  • Mudim uses Alt+/ (not available on the Mac)
  • My AVIM uses F12 (often conflicts with Firefox or OS functions)
  • AVIM for Chrome uses double Ctrl (double ⌃ on the Mac)
  • Google Input Tools uses Ctrl+G (⌃G on the Mac)
  • VietInput has no keyboard shortcut

AVIM for Chrome’s double Ctrl sounds pretty good. (We can keep Ctrl+Alt+V for those who are used to it.) We could possibly improve on this approach by playing a subtle sound cue, like Sticky Keys on Windows and OS X.

Mudim monitor no longer works

The Mudim monitor stopped working in Firefox 4. At the time, I didn’t bother fixing it because Mudim wasn’t available for Firefox 4, but then Mozilla started automatically bumping up its maximum version. Long story short, we need the Mudim monitor again. It should appear at the top of about:addons, like the “restart to install” banner.

Use strict mode in JavaScript

With the javascript.options.strict preference set, Firefox currently warns sometimes when typing using AVIM. We need to get the bottom of these warnings and make use of some modern JavaScript idioms.

  • Convert var to let to prevent hoisting and accidental reuse of variables
  • Fix undeclared variable warnings when typing

Toolbar button looks ugly; convert to SVG

The toolbar button icon is just a quick and dirty placeholder that I whipped up in Seashore. It’s off-center and doesn’t render well on HiDPI screens. Although the built-in Australis toolbar icons are PNGs, I think it’s possible to do a good approximation of the Character Encoding icon, substituting “æ” for “Đ”, in SVG. There may need to be a different version for each platform, but the resulting size will probably be smaller than the current PNG.

Integrate basic preferences into about:addons

AdBlock Plus includes basic preference controls in its about:addons page instead of opening a separate dialog. There is an API for doing so. It’s a terrible UI – checkboxes to the right of their labels? – but arguably more accessible than the separate dialog box. It just feels more integrated.

No toolbar button in Thunderbird

AVIM adds a toolbar button to Firefox’s toolbar palette but not Thunderbird’s. Thunderbird’s status bar is shown by default, so it isn’t such a big deal, but some users may prefer to have AVIM’s controls in the Composition Toolbar.

Extract core input method engine into an XPCOM service

AVIM loads tons and tons of code into every single window. It’s a huge waste and possibly a big performance issue. Mozilla has suggested that we shove everything into a JavaScript module (.jsm), but that would break support for older browsers like Firefox 2.x. (Do we care?) Alternatively, we could move everything into an XPCOM service, which would work in every application AVIM supports.

Convert VNI fonts in PDF.js on copy, find, etc.

Vietnamese text in PDFs is usually typeset in non-Unicode fonts that use VNI, VPS, ABC, or TCVN3 layouts. PDF.js renders this text fine, but the underlying representation is a mangled mess. Because AVIM specializes in Vietnamese input tools, it’s uniquely suited to detecting legacy-encoded Vietnamese text and converting it on the fly when finding or copying inside a PDF.

PDF.js’ text layer includes a <div> for each run of text; each <div> has a data-font-name attribute that identifies the font used for that run. There must be some way to map that identifier to the original font name, which we can then use to guess an encoding. VNI-encoded fonts always begin with “VNI-”, for instance.

Support iWork/iCloud

iCloud doesn’t officially support Firefox, but it seems to work fairly well regardless. It provides more hooks than Google Docs, so we probably won’t have to resort to the fragile copy-paste method.

Handled keystrokes do not trigger autocomplete

The browser’s autocompletion feature fails to update whenever AVIM handles a keystroke by modifying the text, as opposed to letting the keydown event through. AVIM should be sending an input event to tell the browser to autocomplete, but maybe it isn’t getting sent anymore.

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.