Community mailing list archives

Odoo requesting help implementing non-latin languages on POSBox

- 04/19/2016 05:16:39
Hi Odoo Community,

We would like some help from the Arabic, Japanese, Chinese, Taiwanese and Korean speaking Odoo Community. An issue we have always had is that printing receipts in languages that use non-latin alphabets has never worked correctly through the POSBox. The main reason for this is that the ESC/POS protocol we use to talk to the printers does not use UTF-8. Most ESC/POS printers use custom code pages to handle non-latin characters. Epson has a reference displaying these [1]. For Chinese a special format seems to be used by Star that doesn't seem to use code pages at all [2]. Further complicating matters is that most manufacturers do not release POS printers with support for all languages, but limit support to languages used in the region the printers are meant to be sold (eg. for multi-byte Japanese you seem to need a Japanese version of the Epson TM-T20II).

The POSBox receives UTF-8 strings from the browser and will thus need to translate from UTF-8 to an appropriate encoding understood by the printer. Because of the way the ESC/POS protocol works we expect to have to implement every non-latin language seperately.

The reason we like help from the community is that it's not particularly easy to implement support for these languages without intricate knowledge of the language itself. We made some attempts to implement Arabic, but we ended up with an odd-looking word that was built using individual characters that where not correctly 'tied' together indicating that this translation process is more complicated than just translating a UTF-8 character to a similar character in a different code page.

Technical details:
The POSBox runs a local version of Odoo 8 with the hw_* modules loaded [3]. The module in which support should be implemented is hw_escpos. You don't need a POSBox to develop or test these modules, you can locally install them on your machine and directly hook up the printer to your machine. To do this you can follow the POSBoxless guide [4]. A list of supported printers can be found on our website [6].

A good place to start in the code is in [5] in the Escpos.text() function. In here the translation should take place, the function receives a UTF-8 string and then attempts to translate it to something the printer understands. As you can see in the code, a brief attempt was made to support certain Japanese characters, although I'm not sure if that works correctly.

For details surrounding the ESC/POS protocol I would recommend the ESC/POS manual put out by Star [7] which contains a full description of the protocol. Most of the documentation will also apply to Epson devices (although perhaps not the format for Chinese that Star describes).

If you do manage to get a non-latin language working then don't hesitate to create a pull request against Odoo 8 and ping me so I don't miss it (@jorenvo on github).

Don't hesitate to ask if you have any further questions.

Kind regards,