Community mailing list archives
Odoo requesting help implementing non-latin languages on POSBoxby
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 . For Chinese a special format seems to be used by Star that doesn't seem to use code pages at all . 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.
The POSBox runs a local version of Odoo 8 with the hw_* modules loaded . 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 . A list of supported printers can be found on our website .
A good place to start in the code is in escpos.py  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  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.
 pdf p161 in http://www.starasia.com/%5CDownload%5CManual%5Cescpos_cm_en.pdf