Commit 9cebaada authored by plundblad's avatar plundblad Committed by Commit bot

Make undefined Unicode characters show up in a nicer way in braille.

Instead of a cryptic Unicode code point, this makes characters that are not
defined by the current braille table show up as dot 8, which should be
a rarely used cell in most or all braille tables.

While it might be nice to give users more information than a single 'unknown
character' dot, this is the only feasable alternative to the hexadecimal
number (\xHHHH).

BUG=321715

Review URL: https://codereview.chromium.org/589133002

Cr-Commit-Position: refs/heads/master@{#296424}
parent c84602a0
...@@ -145,13 +145,13 @@ cvox.BrailleBackground.prototype.refreshTranslator = function() { ...@@ -145,13 +145,13 @@ cvox.BrailleBackground.prototype.refreshTranslator = function() {
var uncontractedTable = cvox.BrailleTable.getUncontracted( var uncontractedTable = cvox.BrailleTable.getUncontracted(
tables, tables,
table8Dot ? table8Dot : table); table8Dot ? table8Dot : table);
this.liblouis_.getTranslator(table.fileName, goog.bind( this.liblouis_.getTranslator(table.fileNames, goog.bind(
function(translator) { function(translator) {
if (uncontractedTable.id === table.id) { if (uncontractedTable.id === table.id) {
this.displayManager_.setTranslator(translator); this.displayManager_.setTranslator(translator);
this.inputHandler_.setTranslator(translator); this.inputHandler_.setTranslator(translator);
} else { } else {
this.liblouis_.getTranslator(uncontractedTable.fileName, goog.bind( this.liblouis_.getTranslator(uncontractedTable.fileNames, goog.bind(
function(uncontractedTranslator) { function(uncontractedTranslator) {
this.displayManager_.setTranslator( this.displayManager_.setTranslator(
translator, uncontractedTranslator); translator, uncontractedTranslator);
......
...@@ -16,7 +16,7 @@ goog.provide('cvox.BrailleTable'); ...@@ -16,7 +16,7 @@ goog.provide('cvox.BrailleTable');
* id:string, * id:string,
* grade:(string|undefined), * grade:(string|undefined),
* variant:(string|undefined), * variant:(string|undefined),
* fileName:string * fileNames:string
* }} * }}
*/ */
cvox.BrailleTable.Table; cvox.BrailleTable.Table;
...@@ -28,11 +28,25 @@ cvox.BrailleTable.Table; ...@@ -28,11 +28,25 @@ cvox.BrailleTable.Table;
cvox.BrailleTable.TABLE_PATH = 'chromevox/background/braille/tables.json'; cvox.BrailleTable.TABLE_PATH = 'chromevox/background/braille/tables.json';
/**
* @const {string}
* @private
*/
cvox.BrailleTable.COMMON_DEFS_FILENAME_ = 'cvox-common.cti';
/** /**
* Retrieves a list of all available braille tables. * Retrieves a list of all available braille tables.
* @param {function(!Array.<cvox.BrailleTable.Table>)} callback * @param {function(!Array.<cvox.BrailleTable.Table>)} callback
*/ */
cvox.BrailleTable.getAll = function(callback) { cvox.BrailleTable.getAll = function(callback) {
function appendCommonFilename(tables) {
// Append the common definitions to all table filenames.
tables.forEach(function(table) {
table.fileNames += (',' + cvox.BrailleTable.COMMON_DEFS_FILENAME_);
});
return tables;
}
var url = chrome.extension.getURL(cvox.BrailleTable.TABLE_PATH); var url = chrome.extension.getURL(cvox.BrailleTable.TABLE_PATH);
if (!url) { if (!url) {
throw 'Invalid path: ' + cvox.BrailleTable.TABLE_PATH; throw 'Invalid path: ' + cvox.BrailleTable.TABLE_PATH;
...@@ -43,8 +57,10 @@ cvox.BrailleTable.getAll = function(callback) { ...@@ -43,8 +57,10 @@ cvox.BrailleTable.getAll = function(callback) {
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (xhr.readyState == 4) { if (xhr.readyState == 4) {
if (xhr.status == 200) { if (xhr.status == 200) {
callback(/** @type {!Array.<cvox.BrailleTable.Table>} */ ( callback(
JSON.parse(xhr.responseText))); appendCommonFilename(
/** @type {!Array.<cvox.BrailleTable.Table>} */ (
JSON.parse(xhr.responseText))));
} }
} }
}; };
......
...@@ -132,27 +132,28 @@ cvox.LibLouis.prototype.isAttached = function() { ...@@ -132,27 +132,28 @@ cvox.LibLouis.prototype.isAttached = function() {
/** /**
* Returns a translator for the desired table, asynchronously. * Returns a translator for the desired table, asynchronously.
* @param {string} tableName Braille table name for liblouis. * @param {string} tableNames Comma separated list of braille table names for
* liblouis.
* @param {function(cvox.LibLouis.Translator)} callback * @param {function(cvox.LibLouis.Translator)} callback
* Callback which will receive the translator, or {@code null} on failure. * Callback which will receive the translator, or {@code null} on failure.
*/ */
cvox.LibLouis.prototype.getTranslator = cvox.LibLouis.prototype.getTranslator =
function(tableName, callback) { function(tableNames, callback) {
switch (this.instanceState_) { switch (this.instanceState_) {
case cvox.LibLouis.InstanceState.NOT_LOADED: case cvox.LibLouis.InstanceState.NOT_LOADED:
case cvox.LibLouis.InstanceState.LOADING: case cvox.LibLouis.InstanceState.LOADING:
this.pendingTranslators_.push( this.pendingTranslators_.push(
{ tableName: tableName, callback: callback }); { tableNames: tableNames, callback: callback });
return; return;
case cvox.LibLouis.InstanceState.ERROR: case cvox.LibLouis.InstanceState.ERROR:
callback(null /* translator */); callback(null /* translator */);
return; return;
case cvox.LibLouis.InstanceState.LOADED: case cvox.LibLouis.InstanceState.LOADED:
this.rpc_('CheckTable', { 'table_name': tableName }, this.rpc_('CheckTable', { 'table_names': tableNames },
goog.bind(function(reply) { goog.bind(function(reply) {
if (reply['success']) { if (reply['success']) {
var translator = new cvox.LibLouis.Translator( var translator = new cvox.LibLouis.Translator(
this, tableName); this, tableNames);
callback(translator); callback(translator);
} else { } else {
callback(null /* translator */); callback(null /* translator */);
...@@ -198,7 +199,7 @@ cvox.LibLouis.prototype.onInstanceLoad_ = function(e) { ...@@ -198,7 +199,7 @@ cvox.LibLouis.prototype.onInstanceLoad_ = function(e) {
window.console.info('loaded liblouis Native Client instance'); window.console.info('loaded liblouis Native Client instance');
this.instanceState_ = cvox.LibLouis.InstanceState.LOADED; this.instanceState_ = cvox.LibLouis.InstanceState.LOADED;
this.pendingTranslators_.forEach(goog.bind(function(record) { this.pendingTranslators_.forEach(goog.bind(function(record) {
this.getTranslator(record.tableName, record.callback); this.getTranslator(record.tableNames, record.callback);
}, this)); }, this));
this.pendingTranslators_.length = 0; this.pendingTranslators_.length = 0;
}; };
...@@ -213,7 +214,7 @@ cvox.LibLouis.prototype.onInstanceError_ = function(e) { ...@@ -213,7 +214,7 @@ cvox.LibLouis.prototype.onInstanceError_ = function(e) {
window.console.error('failed to load liblouis Native Client instance'); window.console.error('failed to load liblouis Native Client instance');
this.instanceState_ = cvox.LibLouis.InstanceState.ERROR; this.instanceState_ = cvox.LibLouis.InstanceState.ERROR;
this.pendingTranslators_.forEach(goog.bind(function(record) { this.pendingTranslators_.forEach(goog.bind(function(record) {
this.getTranslator(record.tableName, record.callback); this.getTranslator(record.tableNames, record.callback);
}, this)); }, this));
this.pendingTranslators_.length = 0; this.pendingTranslators_.length = 0;
}; };
...@@ -250,9 +251,10 @@ cvox.LibLouis.prototype.onInstanceMessage_ = function(e) { ...@@ -250,9 +251,10 @@ cvox.LibLouis.prototype.onInstanceMessage_ = function(e) {
* Braille translator which uses a Native Client instance of liblouis. * Braille translator which uses a Native Client instance of liblouis.
* @constructor * @constructor
* @param {!cvox.LibLouis} instance The instance wrapper. * @param {!cvox.LibLouis} instance The instance wrapper.
* @param {string} tableName The table name to be passed to liblouis. * @param {string} tableNames Comma separated list of Table names to be passed
* to liblouis.
*/ */
cvox.LibLouis.Translator = function(instance, tableName) { cvox.LibLouis.Translator = function(instance, tableNames) {
/** /**
* The instance wrapper. * The instance wrapper.
* @private {!cvox.LibLouis} * @private {!cvox.LibLouis}
...@@ -263,7 +265,7 @@ cvox.LibLouis.Translator = function(instance, tableName) { ...@@ -263,7 +265,7 @@ cvox.LibLouis.Translator = function(instance, tableName) {
* The table name. * The table name.
* @private {string} * @private {string}
*/ */
this.tableName_ = tableName; this.tableNames_ = tableNames;
}; };
...@@ -277,7 +279,7 @@ cvox.LibLouis.Translator = function(instance, tableName) { ...@@ -277,7 +279,7 @@ cvox.LibLouis.Translator = function(instance, tableName) {
* {@code null}. * {@code null}.
*/ */
cvox.LibLouis.Translator.prototype.translate = function(text, callback) { cvox.LibLouis.Translator.prototype.translate = function(text, callback) {
var message = { 'table_name': this.tableName_, 'text': text }; var message = { 'table_names': this.tableNames_, 'text': text };
this.instance_.rpc_('Translate', message, function(reply) { this.instance_.rpc_('Translate', message, function(reply) {
var cells = null; var cells = null;
var textToBraille = null; var textToBraille = null;
...@@ -314,7 +316,7 @@ cvox.LibLouis.Translator.prototype.backTranslate = ...@@ -314,7 +316,7 @@ cvox.LibLouis.Translator.prototype.backTranslate =
return; return;
} }
var message = { var message = {
'table_name': this.tableName_, 'table_names': this.tableNames_,
'cells': cvox.LibLouis.Translator.encodeHexString_(cells) 'cells': cvox.LibLouis.Translator.encodeHexString_(cells)
}; };
this.instance_.rpc_('BackTranslate', message, function(reply) { this.instance_.rpc_('BackTranslate', message, function(reply) {
......
...@@ -43,7 +43,7 @@ TEST_F('CvoxLibLouisTest', 'checkAllTables', function() { ...@@ -43,7 +43,7 @@ TEST_F('CvoxLibLouisTest', 'checkAllTables', function() {
var checkNextTable = function() { var checkNextTable = function() {
var table = all_tables[i++]; var table = all_tables[i++];
if (table) { if (table) {
this.instance.getTranslator(table.fileName, function(translator) { this.instance.getTranslator(table.fileNames, function(translator) {
assertNotEquals(null, translator, assertNotEquals(null, translator,
'Table ' + table + ' should be valid'); 'Table ' + table + ' should be valid');
checkNextTable(); checkNextTable();
......
...@@ -66,12 +66,12 @@ function expectSuccessReply(callback) { ...@@ -66,12 +66,12 @@ function expectSuccessReply(callback) {
loadLibrary(function() { loadLibrary(function() {
chrome.test.runTests([ chrome.test.runTests([
function testGetTranslator() { function testGetTranslator() {
rpc('CheckTable', { 'table_name': TABLE_NAME}, rpc('CheckTable', { 'table_names': TABLE_NAME},
pass(expectSuccessReply())); pass(expectSuccessReply()));
}, },
function testTranslateString() { function testTranslateString() {
rpc('Translate', { 'table_name': TABLE_NAME, 'text': TEXT}, rpc('Translate', { 'table_names': TABLE_NAME, 'text': TEXT},
pass(expectSuccessReply(function(reply) { pass(expectSuccessReply(function(reply) {
chrome.test.assertEq(CELLS, reply['cells']); chrome.test.assertEq(CELLS, reply['cells']);
}))); })));
...@@ -82,14 +82,14 @@ loadLibrary(function() { ...@@ -82,14 +82,14 @@ loadLibrary(function() {
// letter 'T' should be translated to 3 cells in US English grade 2 // letter 'T' should be translated to 3 cells in US English grade 2
// braille (dots 56, 6, 2345). // braille (dots 56, 6, 2345).
function testTranslateGrade2SingleCapital() { function testTranslateGrade2SingleCapital() {
rpc('Translate', { 'table_name': CONTRACTED_TABLE_NAME, 'text': 'T'}, rpc('Translate', { 'table_names': CONTRACTED_TABLE_NAME, 'text': 'T'},
pass(expectSuccessReply(function(reply) { pass(expectSuccessReply(function(reply) {
chrome.test.assertEq('30201e', reply['cells']); chrome.test.assertEq('30201e', reply['cells']);
}))); })));
}, },
function testBackTranslateString() { function testBackTranslateString() {
rpc('BackTranslate', { 'table_name': TABLE_NAME, 'cells': CELLS}, rpc('BackTranslate', { 'table_names': TABLE_NAME, 'cells': CELLS},
pass(expectSuccessReply(function(reply) { pass(expectSuccessReply(function(reply) {
chrome.test.assertEq(TEXT, reply['text']); chrome.test.assertEq(TEXT, reply['text']);
}))); })));
...@@ -98,7 +98,7 @@ loadLibrary(function() { ...@@ -98,7 +98,7 @@ loadLibrary(function() {
// Backtranslate a one-letter contraction that expands to a much larger // Backtranslate a one-letter contraction that expands to a much larger
// string (k->knowledge). // string (k->knowledge).
function testBackTranslateContracted() { function testBackTranslateContracted() {
rpc('BackTranslate', { 'table_name': CONTRACTED_TABLE_NAME, rpc('BackTranslate', { 'table_names': CONTRACTED_TABLE_NAME,
'cells': '05'}, // dots 1 and 3 'cells': '05'}, // dots 1 and 3
pass(expectSuccessReply(function(reply) { pass(expectSuccessReply(function(reply) {
chrome.test.assertEq('knowledge', reply['text']); chrome.test.assertEq('knowledge', reply['text']);
......
...@@ -19,5 +19,7 @@ Local Modifications: ...@@ -19,5 +19,7 @@ Local Modifications:
* Add manually created liblouis.h with compiler warning fix. * Add manually created liblouis.h with compiler warning fix.
* Add minimal config.h. * Add minimal config.h.
* Add tables.json a list of tables with metadata. * Add tables.json, a list of tables with metadata.
* Add cvox-common.cti with common definitions for all tables mentioned in
tables.json.
* Add a wrapper to expose the library in native client. * Add a wrapper to expose the library in native client.
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Common definitions appended to all braille tables used by liblouis
# in ChromeVox.
# All tables get the Unicode braille patterns. They are included by some
# tables, but not consistently, and adding them again is harmless.
include braille-patterns.cti
# Use dot 8 to represent undefined Unicode characters.
# While not ideal, this is much preferable to the built-in default of
# the code point value preceded by a backslash.
undefined 8
...@@ -66,7 +66,9 @@ def DoMain(argv): ...@@ -66,7 +66,9 @@ def DoMain(argv):
parser.prog = 'liblouis_list_tables' parser.prog = 'liblouis_list_tables'
parser.set_usage('usage: %prog [options] listfile') parser.set_usage('usage: %prog [options] listfile')
parser.add_option('-D', '--directory', dest='directories', parser.add_option('-D', '--directory', dest='directories',
action='append', help='Where to search for table files') action='append', help='Where to search for table files')
parser.add_option('-e', '--extra_file', dest='extra_files', action='append',
default=[], help='Extra liblouis table file to process')
(options, args) = parser.parse_args(argv) (options, args) = parser.parse_args(argv)
if len(args) != 1: if len(args) != 1:
...@@ -77,7 +79,10 @@ def DoMain(argv): ...@@ -77,7 +79,10 @@ def DoMain(argv):
tables = LoadTablesFile(args[0]) tables = LoadTablesFile(args[0])
output_set = set() output_set = set()
for table in tables: for table in tables:
ProcessFile(output_set, table['fileName'], options.directories) for name in table['fileNames'].split(','):
ProcessFile(output_set, name, options.directories)
for name in options.extra_files:
ProcessFile(output_set, name, options.directories)
return '\n'.join(output_set) return '\n'.join(output_set)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
'braille_test_data_dir': '<(PRODUCT_DIR)/chromevox_test_data/braille', 'braille_test_data_dir': '<(PRODUCT_DIR)/chromevox_test_data/braille',
'braille_chromevox_dir': '<(PRODUCT_DIR)/resources/chromeos/chromevox/chromevox/background/braille', 'braille_chromevox_dir': '<(PRODUCT_DIR)/resources/chromeos/chromevox/chromevox/background/braille',
'table_files': [ 'table_files': [
'>!@pymod_do_main(liblouis_list_tables -D overrides/tables -D src/tables tables.json)', '>!@pymod_do_main(liblouis_list_tables -D . -D src/tables -e cvox-common.cti tables.json)',
], ],
}, },
# x86 targets build both 32 and 64 bit binaries by default. We only need # x86 targets build both 32 and 64 bit binaries by default. We only need
......
...@@ -104,7 +104,7 @@ static const char kCommandKey[] = "command"; ...@@ -104,7 +104,7 @@ static const char kCommandKey[] = "command";
static const char kMessageIdKey[] = "message_id"; static const char kMessageIdKey[] = "message_id";
static const char kInReplyToKey[] = "in_reply_to"; static const char kInReplyToKey[] = "in_reply_to";
static const char kErrorKey[] = "error"; static const char kErrorKey[] = "error";
static const char kTableNameKey[] = "table_name"; static const char kTableNamesKey[] = "table_names";
static const char kSuccessKey[] = "success"; static const char kSuccessKey[] = "success";
static const char kTextKey[] = "text"; static const char kTextKey[] = "text";
static const char kCellsKey[] = "cells"; static const char kCellsKey[] = "cells";
...@@ -208,23 +208,23 @@ void LibLouisInstance::PostError(const std::string& error_message, ...@@ -208,23 +208,23 @@ void LibLouisInstance::PostError(const std::string& error_message,
void LibLouisInstance::HandleCheckTable(const Json::Value& message, void LibLouisInstance::HandleCheckTable(const Json::Value& message,
const std::string& message_id) { const std::string& message_id) {
Json::Value table_name = message[kTableNameKey]; Json::Value table_names = message[kTableNamesKey];
if (!table_name.isString()) { if (!table_names.isString()) {
PostError("expected table_name to be a string", message_id); PostError("expected table_names to be a string", message_id);
return; return;
} }
PostWorkToBackground(cc_factory_.NewCallback( PostWorkToBackground(cc_factory_.NewCallback(
&LibLouisInstance::CheckTableInBackground, &LibLouisInstance::CheckTableInBackground,
table_name.asString(), message_id)); table_names.asString(), message_id));
} }
void LibLouisInstance::CheckTableInBackground(int32_t result, void LibLouisInstance::CheckTableInBackground(int32_t result,
const std::string& table_name, const std::string& message_id) { const std::string& table_names, const std::string& message_id) {
if (result != PP_OK) { if (result != PP_OK) {
PostError("failed to transfer call to background thread", message_id); PostError("failed to transfer call to background thread", message_id);
return; return;
} }
bool success = liblouis_.CheckTable(table_name); bool success = liblouis_.CheckTable(table_names);
Json::Value reply(Json::objectValue); Json::Value reply(Json::objectValue);
reply[kSuccessKey] = success; reply[kSuccessKey] = success;
PostReply(reply, message_id); PostReply(reply, message_id);
...@@ -232,11 +232,11 @@ void LibLouisInstance::CheckTableInBackground(int32_t result, ...@@ -232,11 +232,11 @@ void LibLouisInstance::CheckTableInBackground(int32_t result,
void LibLouisInstance::HandleTranslate(const Json::Value& message, void LibLouisInstance::HandleTranslate(const Json::Value& message,
const std::string& message_id) { const std::string& message_id) {
Json::Value table_name = message[kTableNameKey]; Json::Value table_names = message[kTableNamesKey];
Json::Value text = message[kTextKey]; Json::Value text = message[kTextKey];
Json::Value cursor_position = message[kCursorPositionKey]; Json::Value cursor_position = message[kCursorPositionKey];
if (!table_name.isString()) { if (!table_names.isString()) {
PostError("expected table_name to be a string", message_id); PostError("expected table_names to be a string", message_id);
return; return;
} else if (!text.isString()) { } else if (!text.isString()) {
PostError("expected text to be a string", message_id); PostError("expected text to be a string", message_id);
...@@ -246,7 +246,7 @@ void LibLouisInstance::HandleTranslate(const Json::Value& message, ...@@ -246,7 +246,7 @@ void LibLouisInstance::HandleTranslate(const Json::Value& message,
return; return;
} }
TranslationParams params; TranslationParams params;
params.table_name = table_name.asString(); params.table_names = table_names.asString();
params.text = text.asString(); params.text = text.asString();
params.cursor_position = cursor_position.isIntegral() ? params.cursor_position = cursor_position.isIntegral() ?
cursor_position.asInt() : -1; cursor_position.asInt() : -1;
...@@ -284,10 +284,10 @@ void LibLouisInstance::TranslateInBackground(int32_t result, ...@@ -284,10 +284,10 @@ void LibLouisInstance::TranslateInBackground(int32_t result,
void LibLouisInstance::HandleBackTranslate(const Json::Value& message, void LibLouisInstance::HandleBackTranslate(const Json::Value& message,
const std::string& message_id) { const std::string& message_id) {
Json::Value table_name = message[kTableNameKey]; Json::Value table_names = message[kTableNamesKey];
Json::Value cells = message[kCellsKey]; Json::Value cells = message[kCellsKey];
if (!table_name.isString()) { if (!table_names.isString()) {
PostError("expected table_name to be a string", message_id); PostError("expected table_names to be a string", message_id);
return; return;
} else if (!cells.isString()) { } else if (!cells.isString()) {
PostError("expected cells to be a string", message_id); PostError("expected cells to be a string", message_id);
...@@ -300,18 +300,18 @@ void LibLouisInstance::HandleBackTranslate(const Json::Value& message, ...@@ -300,18 +300,18 @@ void LibLouisInstance::HandleBackTranslate(const Json::Value& message,
} }
PostWorkToBackground(cc_factory_.NewCallback( PostWorkToBackground(cc_factory_.NewCallback(
&LibLouisInstance::BackTranslateInBackground, &LibLouisInstance::BackTranslateInBackground,
table_name.asString(), cells_vector, message_id)); table_names.asString(), cells_vector, message_id));
} }
void LibLouisInstance::BackTranslateInBackground(int32_t result, void LibLouisInstance::BackTranslateInBackground(int32_t result,
const std::string& table_name, const std::vector<unsigned char>& cells, const std::string& table_names, const std::vector<unsigned char>& cells,
const std::string& message_id) { const std::string& message_id) {
if (result != PP_OK) { if (result != PP_OK) {
PostError("failed to transfer call to background thread", message_id); PostError("failed to transfer call to background thread", message_id);
return; return;
} }
std::string text; std::string text;
bool success = liblouis_.BackTranslate(table_name, cells, &text); bool success = liblouis_.BackTranslate(table_names, cells, &text);
Json::Value reply(Json::objectValue); Json::Value reply(Json::objectValue);
reply[kSuccessKey] = success; reply[kSuccessKey] = success;
if (success) { if (success) {
......
...@@ -60,7 +60,7 @@ class LibLouisInstance : public pp::Instance { ...@@ -60,7 +60,7 @@ class LibLouisInstance : public pp::Instance {
const std::string& message_id); const std::string& message_id);
// Called to check a table on a background thread. // Called to check a table on a background thread.
void CheckTableInBackground(int32_t result, const std::string& table_name, void CheckTableInBackground(int32_t result, const std::string& table_names,
const std::string& message_id); const std::string& message_id);
// Parses and executes a translation command. // Parses and executes a translation command.
...@@ -77,7 +77,7 @@ class LibLouisInstance : public pp::Instance { ...@@ -77,7 +77,7 @@ class LibLouisInstance : public pp::Instance {
// Called to back-translate text on a background thread. // Called to back-translate text on a background thread.
void BackTranslateInBackground(int32_t result, void BackTranslateInBackground(int32_t result,
const std::string& table_name, const std::vector<unsigned char>& cells, const std::string& table_names, const std::vector<unsigned char>& cells,
const std::string& message_id); const std::string& message_id);
LibLouisWrapper liblouis_; LibLouisWrapper liblouis_;
......
...@@ -109,8 +109,8 @@ const char* LibLouisWrapper::tables_dir() const { ...@@ -109,8 +109,8 @@ const char* LibLouisWrapper::tables_dir() const {
return "/liblouis/tables"; return "/liblouis/tables";
} }
bool LibLouisWrapper::CheckTable(const std::string& table_name) { bool LibLouisWrapper::CheckTable(const std::string& table_names) {
return lou_getTable(table_name.c_str()) != NULL; return lou_getTable(table_names.c_str()) != NULL;
} }
bool LibLouisWrapper::Translate(const TranslationParams& params, bool LibLouisWrapper::Translate(const TranslationParams& params,
...@@ -152,7 +152,7 @@ bool LibLouisWrapper::Translate(const TranslationParams& params, ...@@ -152,7 +152,7 @@ bool LibLouisWrapper::Translate(const TranslationParams& params,
outlen = outalloc; outlen = outalloc;
outbuf.resize(outalloc); outbuf.resize(outalloc);
braille_to_text.resize(outalloc); braille_to_text.resize(outalloc);
int result = lou_translate(params.table_name.c_str(), int result = lou_translate(params.table_names.c_str(),
&inbuf[0], &inlen, &outbuf[0], &outlen, &inbuf[0], &inlen, &outbuf[0], &outlen,
NULL /* typeform */, NULL /* spacing */, NULL /* typeform */, NULL /* spacing */,
&text_to_braille[0], &braille_to_text[0], &text_to_braille[0], &braille_to_text[0],
...@@ -188,7 +188,7 @@ bool LibLouisWrapper::Translate(const TranslationParams& params, ...@@ -188,7 +188,7 @@ bool LibLouisWrapper::Translate(const TranslationParams& params,
return true; return true;
} }
bool LibLouisWrapper::BackTranslate(const std::string& table_name, bool LibLouisWrapper::BackTranslate(const std::string& table_names,
const std::vector<unsigned char>& cells, std::string* out) { const std::vector<unsigned char>& cells, std::string* out) {
std::vector<widechar> inbuf; std::vector<widechar> inbuf;
inbuf.reserve(cells.size()); inbuf.reserve(cells.size());
...@@ -215,7 +215,7 @@ bool LibLouisWrapper::BackTranslate(const std::string& table_name, ...@@ -215,7 +215,7 @@ bool LibLouisWrapper::BackTranslate(const std::string& table_name,
outbuf.resize(outalloc); outbuf.resize(outalloc);
int result = lou_backTranslateString( int result = lou_backTranslateString(
table_name.c_str(), &inbuf[0], &inlen, &outbuf[0], &outlen, table_names.c_str(), &inbuf[0], &inlen, &outbuf[0], &outlen,
NULL /* typeform */, NULL /* spacing */, dotsIO /* mode */); NULL /* typeform */, NULL /* spacing */, dotsIO /* mode */);
if (result == 0) { if (result == 0) {
// TODO(jbroman): log this // TODO(jbroman): log this
......
...@@ -40,13 +40,13 @@ class LibLouisWrapper { ...@@ -40,13 +40,13 @@ class LibLouisWrapper {
// Loads, checks, and compiles the requested table. // Loads, checks, and compiles the requested table.
// Returns true on success. // Returns true on success.
bool CheckTable(const std::string& table_name); bool CheckTable(const std::string& table_names);
// Translates the given text and cursor position into braille. // Translates the given text and cursor position into braille.
bool Translate(const TranslationParams& params, TranslationResult* out); bool Translate(const TranslationParams& params, TranslationResult* out);
// Translates the given braille cells into text. // Translates the given braille cells into text.
bool BackTranslate(const std::string& table_name, bool BackTranslate(const std::string& table_names,
const std::vector<unsigned char>& cells, std::string* out); const std::vector<unsigned char>& cells, std::string* out);
private: private:
......
...@@ -22,7 +22,7 @@ namespace liblouis_nacl { ...@@ -22,7 +22,7 @@ namespace liblouis_nacl {
// Struct containing the parameters of translation. // Struct containing the parameters of translation.
struct TranslationParams { struct TranslationParams {
public: public:
std::string table_name; std::string table_names;
std::string text; std::string text;
int cursor_position; int cursor_position;
}; };
......
...@@ -4,128 +4,128 @@ ...@@ -4,128 +4,128 @@
"locale": "ar", "locale": "ar",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "ar-ar-g1.utb" "fileNames": "ar-ar-g1.utb"
}, },
{ {
"id": "bg-comp8", "id": "bg-comp8",
"locale": "bg", "locale": "bg",
"dots": "8", "dots": "8",
"fileName": "bg.ctb" "fileNames": "bg.ctb"
}, },
{ {
"id": "ca-g1", "id": "ca-g1",
"locale": "ca", "locale": "ca",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "ca-g1.ctb" "fileNames": "ca-g1.ctb"
}, },
{ {
"id": "cs-g1", "id": "cs-g1",
"locale": "cs", "locale": "cs",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "cs-g1.ctb" "fileNames": "cs-g1.ctb"
}, },
{ {
"id": "da-comp8", "id": "da-comp8",
"locale": "da", "locale": "da",
"dots": "8", "dots": "8",
"fileName": "da-dk-g18.utb" "fileNames": "da-dk-g18.utb"
}, },
{ {
"id": "da-g1", "id": "da-g1",
"locale": "da", "locale": "da",
"dots": "6", "dots": "6",
"grade": 1, "grade": 1,
"fileName": "da-dk-g16.utb" "fileNames": "da-dk-g16.utb"
}, },
{ {
"id": "da-g2", "id": "da-g2",
"locale": "da", "locale": "da",
"dots": "6", "dots": "6",
"grade": 2, "grade": 2,
"fileName": "da-dk-g26.ctb" "fileNames": "da-dk-g26.ctb"
}, },
{ {
"id": "de-CH-g0", "id": "de-CH-g0",
"locale": "de_CH", "locale": "de_CH",
"dots": "6", "dots": "6",
"grade": "0", "grade": "0",
"fileName": "de-ch-g0.utb" "fileNames": "de-ch-g0.utb"
}, },
{ {
"id": "de-CH-g1", "id": "de-CH-g1",
"locale": "de_CH", "locale": "de_CH",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "de-ch-g1.ctb" "fileNames": "de-ch-g1.ctb"
}, },
{ {
"id": "de-CH-g2", "id": "de-CH-g2",
"locale": "de_CH", "locale": "de_CH",
"dots": "6", "dots": "6",
"grade": "2", "grade": "2",
"fileName": "de-ch-g2.ctb" "fileNames": "de-ch-g2.ctb"
}, },
{ {
"id": "de-DE-g0", "id": "de-DE-g0",
"locale": "de_DE", "locale": "de_DE",
"dots": "6", "dots": "6",
"grade": "0", "grade": "0",
"fileName": "de-de-g0.utb" "fileNames": "de-de-g0.utb"
}, },
{ {
"id": "de-DE-g1", "id": "de-DE-g1",
"locale": "de_DE", "locale": "de_DE",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "de-de-g1.ctb" "fileNames": "de-de-g1.ctb"
}, },
{ {
"id": "de-DE-g2", "id": "de-DE-g2",
"locale": "de_DE", "locale": "de_DE",
"dots": "6", "dots": "6",
"grade": "2", "grade": "2",
"fileName": "de-de-g2.ctb" "fileNames": "de-de-g2.ctb"
}, },
{ {
"id": "de-comp8", "id": "de-comp8",
"locale": "de", "locale": "de",
"dots": "8", "dots": "8",
"fileName": "de-de-comp8.ctb" "fileNames": "de-de-comp8.ctb"
}, },
{ {
"id": "el-g1", "id": "el-g1",
"locale": "el", "locale": "el",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "gr-gr-g1.utb" "fileNames": "gr-gr-g1.utb"
}, },
{ {
"id": "en-CA-comp8", "id": "en-CA-comp8",
"locale": "en_CA", "locale": "en_CA",
"dots": "8", "dots": "8",
"fileName": "en_CA.ctb" "fileNames": "en_CA.ctb"
}, },
{ {
"id": "en-GB-comp8", "id": "en-GB-comp8",
"locale": "en_GB", "locale": "en_GB",
"dots": "8", "dots": "8",
"fileName": "en-gb-comp8.ctb" "fileNames": "en-gb-comp8.ctb"
}, },
{ {
"id": "en-GB-g1", "id": "en-GB-g1",
"locale": "en_GB", "locale": "en_GB",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "en-gb-g1.utb" "fileNames": "en-gb-g1.utb"
}, },
{ {
"id": "en-GB-g2", "id": "en-GB-g2",
"locale": "en_GB", "locale": "en_GB",
"dots": "6", "dots": "6",
"grade": "2", "grade": "2",
"fileName": "en-GB-g2.ctb" "fileNames": "en-GB-g2.ctb"
}, },
{ {
"id": "en-UEB-g1", "id": "en-UEB-g1",
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
"variant": "UEB", "variant": "UEB",
"dots": "6", "dots": "6",
"grade": 1, "grade": 1,
"fileName": "en-ueb-g1.ctb" "fileNames": "en-ueb-g1.ctb"
}, },
{ {
"id": "en-UEB-g2", "id": "en-UEB-g2",
...@@ -141,314 +141,314 @@ ...@@ -141,314 +141,314 @@
"variant": "UEB", "variant": "UEB",
"dots": "6", "dots": "6",
"grade": 2, "grade": 2,
"fileName": "en-ueb-g2.ctb" "fileNames": "en-ueb-g2.ctb"
}, },
{ {
"id": "en-US-comp8", "id": "en-US-comp8",
"locale": "en_US", "locale": "en_US",
"dots": "8", "dots": "8",
"fileName": "en-us-comp8.ctb" "fileNames": "en-us-comp8.ctb"
}, },
{ {
"id": "en-US-g1", "id": "en-US-g1",
"locale": "en_US", "locale": "en_US",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "en-us-g1.ctb" "fileNames": "en-us-g1.ctb"
}, },
{ {
"id": "en-US-g2", "id": "en-US-g2",
"locale": "en_US", "locale": "en_US",
"dots": "6", "dots": "6",
"grade": "2", "grade": "2",
"fileName": "en-us-g2.ctb" "fileNames": "en-us-g2.ctb"
}, },
{ {
"id": "es-comp8", "id": "es-comp8",
"locale": "es", "locale": "es",
"dots": "8", "dots": "8",
"fileName": "Es-Es-G0.utb" "fileNames": "Es-Es-G0.utb"
}, },
{ {
"id": "es-g1", "id": "es-g1",
"locale": "es", "locale": "es",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "es-g1.ctb" "fileNames": "es-g1.ctb"
}, },
{ {
"id": "et-comp8", "id": "et-comp8",
"locale": "et", "locale": "et",
"dots": "8", "dots": "8",
"fileName": "et-g0.utb" "fileNames": "et-g0.utb"
}, },
{ {
"id": "fr-CA-g1", "id": "fr-CA-g1",
"locale": "fr_CA", "locale": "fr_CA",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "fr-ca-g1.utb" "fileNames": "fr-ca-g1.utb"
}, },
{ {
"id": "fr-CA-g2", "id": "fr-CA-g2",
"locale": "fr_CA", "locale": "fr_CA",
"dots": "6", "dots": "6",
"grade": "2", "grade": "2",
"fileName": "Fr-Ca-g2.ctb" "fileNames": "Fr-Ca-g2.ctb"
}, },
{ {
"id": "fr-FR-g1", "id": "fr-FR-g1",
"locale": "fr_FR", "locale": "fr_FR",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "fr-fr-g1.utb" "fileNames": "fr-fr-g1.utb"
}, },
{ {
"id": "fr-FR-g2", "id": "fr-FR-g2",
"locale": "fr_FR", "locale": "fr_FR",
"dots": "6", "dots": "6",
"grade": "2", "grade": "2",
"fileName": "Fr-Fr-g2.ctb" "fileNames": "Fr-Fr-g2.ctb"
}, },
{ {
"id": "fr-comp8", "id": "fr-comp8",
"locale": "fr", "locale": "fr",
"dots": "8", "dots": "8",
"fileName": "fr-2007.ctb" "fileNames": "fr-2007.ctb"
}, },
{ {
"id": "fi-comp8", "id": "fi-comp8",
"locale": "fi", "locale": "fi",
"dots": "8", "dots": "8",
"fileName": "fi-fi-8dot.ctb" "fileNames": "fi-fi-8dot.ctb"
}, },
{ {
"id": "he-comp8", "id": "he-comp8",
"locale": "he", "locale": "he",
"dots": "8", "dots": "8",
"fileName": "he.ctb" "fileNames": "he.ctb"
}, },
{ {
"id": "hi-g1", "id": "hi-g1",
"locale": "hi", "locale": "hi",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "hi-in-g1.utb" "fileNames": "hi-in-g1.utb"
}, },
{ {
"id": "hr-comp8", "id": "hr-comp8",
"locale": "hr", "locale": "hr",
"dots": "8", "dots": "8",
"fileName": "hr.ctb" "fileNames": "hr.ctb"
}, },
{ {
"id": "hu-comp8", "id": "hu-comp8",
"locale": "hu", "locale": "hu",
"dots": "8", "dots": "8",
"fileName": "hu-hu-comp8.ctb" "fileNames": "hu-hu-comp8.ctb"
}, },
{ {
"id": "hu-g1", "id": "hu-g1",
"locale": "hu", "locale": "hu",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "hu-hu-g1.ctb" "fileNames": "hu-hu-g1.ctb"
}, },
{ {
"id": "is-comp8", "id": "is-comp8",
"locale": "is", "locale": "is",
"dots": "8", "dots": "8",
"fileName": "is.ctb" "fileNames": "is.ctb"
}, },
{ {
"id": "it-comp8", "id": "it-comp8",
"locale": "it", "locale": "it",
"dots": "8", "dots": "8",
"fileName": "it-it-comp8.utb" "fileNames": "it-it-comp8.utb"
}, },
{ {
"id": "it-g1", "id": "it-g1",
"locale": "it", "locale": "it",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "it-it-comp6.utb" "fileNames": "it-it-comp6.utb"
}, },
{ {
"id": "ko-g1", "id": "ko-g1",
"locale": "ko", "locale": "ko",
"dots": "6", "dots": "6",
"grade": 1, "grade": 1,
"fileName": "ko-g1.ctb" "fileNames": "ko-g1.ctb"
}, },
{ {
"id": "ko-g2", "id": "ko-g2",
"locale": "ko", "locale": "ko",
"dots": "6", "dots": "6",
"grade": 2, "grade": 2,
"fileName": "ko-g2.ctb" "fileNames": "ko-g2.ctb"
}, },
{ {
"id": "lv-g1", "id": "lv-g1",
"locale": "lv", "locale": "lv",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "Lv-Lv-g1.utb" "fileNames": "Lv-Lv-g1.utb"
}, },
{ {
"id": "lt-comp8", "id": "lt-comp8",
"locale": "lt", "locale": "lt",
"dots": "8", "dots": "8",
"fileName": "lt.ctb" "fileNames": "lt.ctb"
}, },
{ {
"id": "nb-comp8", "id": "nb-comp8",
"locale": "nb", "locale": "nb",
"dots": "8", "dots": "8",
"fileName": "no-no.ctb" "fileNames": "no-no.ctb"
}, },
{ {
"id": "nb-g0", "id": "nb-g0",
"locale": "nb", "locale": "nb",
"dots": "6", "dots": "6",
"grade": "0", "grade": "0",
"fileName": "no-no-g0.utb" "fileNames": "no-no-g0.utb"
}, },
{ {
"id": "nb-g1", "id": "nb-g1",
"locale": "nb", "locale": "nb",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "no-no-g1.ctb" "fileNames": "no-no-g1.ctb"
}, },
{ {
"id": "nb-g2", "id": "nb-g2",
"locale": "nb", "locale": "nb",
"dots": "6", "dots": "6",
"grade": "2", "grade": "2",
"fileName": "no-no-g2.ctb" "fileNames": "no-no-g2.ctb"
}, },
{ {
"id": "nb-g3", "id": "nb-g3",
"locale": "nb", "locale": "nb",
"dots": "6", "dots": "6",
"grade": "3", "grade": "3",
"fileName": "no-no-g3.ctb" "fileNames": "no-no-g3.ctb"
}, },
{ {
"id": "nl-g1", "id": "nl-g1",
"locale": "nl", "locale": "nl",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "Nl-Nl-g1.utb" "fileNames": "Nl-Nl-g1.utb"
}, },
{ {
"id": "pl-g1", "id": "pl-g1",
"locale": "pl", "locale": "pl",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "Pl-Pl-g1.utb" "fileNames": "Pl-Pl-g1.utb"
}, },
{ {
"id": "pt-comp8", "id": "pt-comp8",
"locale": "pt", "locale": "pt",
"dots": "8", "dots": "8",
"fileName": "pt-pt-comp8.ctb" "fileNames": "pt-pt-comp8.ctb"
}, },
{ {
"id": "pt-g1", "id": "pt-g1",
"locale": "pt", "locale": "pt",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "pt-pt-g1.utb" "fileNames": "pt-pt-g1.utb"
}, },
{ {
"id": "pt-g2", "id": "pt-g2",
"locale": "pt", "locale": "pt",
"dots": "6", "dots": "6",
"grade": "2", "grade": "2",
"fileName": "pt-pt-g2.ctb" "fileNames": "pt-pt-g2.ctb"
}, },
{ {
"id": "ro-comp8", "id": "ro-comp8",
"locale": "ro", "locale": "ro",
"dots": "8", "dots": "8",
"fileName": "ro.ctb" "fileNames": "ro.ctb"
}, },
{ {
"id": "ru-comp8", "id": "ru-comp8",
"locale": "ru", "locale": "ru",
"dots": "8", "dots": "8",
"fileName": "ru-compbrl.ctb" "fileNames": "ru-compbrl.ctb"
}, },
{ {
"id": "ru-g1", "id": "ru-g1",
"locale": "ru", "locale": "ru",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "ru-litbrl.ctb" "fileNames": "ru-litbrl.ctb"
}, },
{ {
"id": "sk-g1", "id": "sk-g1",
"locale": "sk", "locale": "sk",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "sk-sk-g1.utb" "fileNames": "sk-sk-g1.utb"
}, },
{ {
"id": "sl-comp8", "id": "sl-comp8",
"locale": "sl", "locale": "sl",
"dots": "8", "dots": "8",
"fileName": "sl-si-comp8.ctb" "fileNames": "sl-si-comp8.ctb"
}, },
{ {
"id": "sl-g1", "id": "sl-g1",
"locale": "sl", "locale": "sl",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "sl-si-g1.utb" "fileNames": "sl-si-g1.utb"
}, },
{ {
"id": "sr-g1", "id": "sr-g1",
"locale": "sr", "locale": "sr",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "sr-g1.ctb" "fileNames": "sr-g1.ctb"
}, },
{ {
"id": "sv-comp8", "id": "sv-comp8",
"locale": "sv", "locale": "sv",
"dots": "8", "dots": "8",
"fileName": "sv-1996.ctb" "fileNames": "sv-1996.ctb"
}, },
{ {
"id": "sv-g1", "id": "sv-g1",
"locale": "sv", "locale": "sv",
"dots": "6", "dots": "6",
"grade": "1", "grade": "1",
"fileName": "Se-Se-g1.utb" "fileNames": "Se-Se-g1.utb"
}, },
{ {
"id": "tr-comp8", "id": "tr-comp8",
"locale": "tr", "locale": "tr",
"dots": "8", "dots": "8",
"fileName": "tr.ctb" "fileNames": "tr.ctb"
}, },
{ {
"id": "vi-comp8", "id": "vi-comp8",
"locale": "vi", "locale": "vi",
"dots": "8", "dots": "8",
"fileName": "vi.ctb" "fileNames": "vi.ctb"
}, },
{ {
"id": "zh-TW-comp8", "id": "zh-TW-comp8",
"locale": "zh_TW", "locale": "zh_TW",
"dots": "8", "dots": "8",
"fileName": "zh-tw.ctb" "fileNames": "zh-tw.ctb"
}, },
{ {
"id": "zh-comp8", "id": "zh-comp8",
"locale": "zh", "locale": "zh",
"dots": "8", "dots": "8",
"fileName": "zh-hk.ctb" "fileNames": "zh-hk.ctb"
} }
] ]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment