From 6fe61036325c86ed6e572d0676f1272d67ae1bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Eixarch?= Date: Mon, 26 Nov 2012 23:40:31 +0100 Subject: [PATCH 1/6] added languages for translatewiki --- src/locales/zh-hant.ini | 78 ----------------------------------------- src/node/hooks/i18n.js | 4 +-- src/package.json | 52 +++++++++++++-------------- 3 files changed, 28 insertions(+), 106 deletions(-) delete mode 100644 src/locales/zh-hant.ini diff --git a/src/locales/zh-hant.ini b/src/locales/zh-hant.ini deleted file mode 100644 index b76ae180..00000000 --- a/src/locales/zh-hant.ini +++ /dev/null @@ -1,78 +0,0 @@ -; Exported from translatewiki.net -; Author: Simon Shek -[zh-hant] -index.newPad = 新Pad -index.createOpenPad = 或創建/開啟以下名稱的pad: -pad.toolbar.bold.title = 粗體(Ctrl-B) -pad.toolbar.italic.title = 斜體(Ctrl-I) -pad.toolbar.underline.title = 底線(Ctrl-U) -pad.toolbar.strikethrough.title = 刪除線 -pad.toolbar.ol.title = 有序清單 -pad.toolbar.ul.title = 無序清單 -pad.toolbar.indent.title = 縮排 -pad.toolbar.unindent.title = 凸排 -pad.toolbar.undo.title = 撤銷(Ctrl-Z) -pad.toolbar.redo.title = 重做(Ctrl-Y) -pad.toolbar.clearAuthorship.title = 清除作名顏色 -pad.toolbar.import_export.title = 以其他檔案格式導入/匯出 -pad.toolbar.timeslider.title = 時間軸 -pad.toolbar.savedRevision.title = 已儲存的修訂 -pad.toolbar.settings.title = 設定 -pad.toolbar.embed.title = 嵌入此pad -pad.toolbar.showusers.title = 顯示此pad的用戶 -pad.colorpicker.save = 儲存 -pad.colorpicker.cancel = 取消 -pad.loading = 載入中... -pad.settings.padSettings = Pad設定 -pad.settings.myView = 我的視窗 -pad.settings.stickychat = 永遠在屏幕上顯示聊天 -pad.settings.colorcheck = 作者顏色 -pad.settings.linenocheck = 行號 -pad.settings.fontType = 字體類型: -pad.settings.fontType.normal = 正常 -pad.settings.fontType.monospaced = 等寬 -pad.settings.globalView = 所有人的視窗 -pad.settings.language = 語言: -pad.importExport.import_export = 導入/匯出 -pad.importExport.import = 上載任何文字檔或文檔 -pad.importExport.successful = 完成! -pad.importExport.export = 匯出當前pad為: -pad.importExport.exporthtml = HTML -pad.importExport.exportplain = 純文字 -pad.importExport.exportword = Microsoft Word -pad.importExport.exportpdf = PDF -pad.importExport.exportopen = ODF(開放文件格式) -pad.importExport.exportdokuwiki = DokuWiki -pad.modals.connected = 已連線。 -pad.modals.reconnecting = 重新連接到您的pad... -pad.modals.forcereconnect = 強制重新連線 -pad.modals.uderdup = 在另一個視窗中開啟 -pad.modals.userdup.explanation = 此pad似乎在此電腦上的多個瀏覽器視窗中開啟。 -pad.modals.userdup.advice = 重新連接到此視窗。 -pad.modals.unauth = 未授權 -pad.modals.unauth.explanation = 您的權限在查看此頁時發生更改。請嘗試重新連接。 -pad.modals.looping = 已離線。 -pad.modals.looping.explanation = 與同步伺服器間有通信問題。 -pad.modals.looping.cause = 也許您通過一個不相容的防火牆或代理伺服器連接。 -pad.modals.initsocketfail = 無法訪問伺服器。 -pad.modals.initsocketfail.explanation = 無法連接到同步伺服器。 -pad.modals.initsocketfail.cause = 可能是由於您的瀏覽器或您的互聯網連接的問題。 -pad.modals.slowcommit = 已離線。 -pad.modals.slowcommit.explanation = 伺服器沒有回應。 -pad.modals.slowcommit.cause = 可能是由於網路連接問題。 -pad.modals.deleted = 已刪除。 -pad.modals.deleted.explanation = 此pad已被移除。 -pad.modals.disconnected = 您已中斷連線。 -pad.modals.disconnected.explanation = 伺服器連接曾中斷 -pad.modals.disconnected.cause = 伺服器可能無法使用。若此情況持續發生,請通知我們。 -pad.share = 分享此pad -pad.share.readonly = 唯讀 -pad.share.link = 連結 -pad.share.emebdcode = 嵌入網址 -pad.chat = 聊天 -pad.chat.title = 打開此pad的聊天。 -timeslider.pageTitle = {{appTitle}}時間軸 -timeslider.toolbar.returnbutton = 返回到pad -timeslider.toolbar.authors = 作者: -timeslider.toolbar.authorsList = 無作者 -timeslider.exportCurrent = 匯出當前版本為: diff --git a/src/node/hooks/i18n.js b/src/node/hooks/i18n.js index 4d42de04..f6f0f8c8 100644 --- a/src/node/hooks/i18n.js +++ b/src/node/hooks/i18n.js @@ -1,4 +1,4 @@ -var languages = require('languages') +var languages = require('languages4translatewiki') , fs = require('fs') , path = require('path') , express = require('express') @@ -9,7 +9,7 @@ var localesPath = __dirname+"/../../locales"; var localeIndex = fs.readFileSync(localesPath+'/en.ini')+'\r\n'; // add language base 'en' to availableLangs -exports.availableLangs = {en: languages.getLanguageInfo('en')} +exports.availableLangs = {en: {name:'English',nativeName:'English',direction:'ltr'}}; fs.readdir(localesPath, function(er, files) { files.forEach(function(locale) { diff --git a/src/package.json b/src/package.json index 8f762077..24bcdd84 100644 --- a/src/package.json +++ b/src/package.json @@ -11,32 +11,32 @@ { "name": "Marcel Klehr" } ], "dependencies" : { - "yajsml" : "1.1.6", - "request" : "2.9.100", - "require-kernel" : "1.0.5", - "resolve" : "0.2.x", - "socket.io" : "0.9.x", - "ueberDB" : "0.1.8", - "async" : "0.1.x", - "express" : "3.x", - "connect" : "2.4.x", - "clean-css" : "0.3.2", - "uglify-js" : "1.2.5", - "formidable" : "1.0.9", - "log4js" : "0.5.x", - "jsdom-nocontextifiy" : "0.2.10", - "async-stacktrace" : "0.0.2", - "npm" : "1.1.x", - "npm-registry-client" : "0.2.10", - "ejs" : "0.6.1", - "graceful-fs" : "1.1.5", - "slide" : "1.1.3", - "semver" : "1.0.13", - "security" : "1.0.0", - "tinycon" : "0.0.1", - "underscore" : "1.3.1", - "unorm" : "1.0.0", - "languages" : "0.1.1" + "yajsml" : "1.1.6", + "request" : "2.9.100", + "require-kernel" : "1.0.5", + "resolve" : "0.2.x", + "socket.io" : "0.9.x", + "ueberDB" : "0.1.8", + "async" : "0.1.x", + "express" : "3.x", + "connect" : "2.4.x", + "clean-css" : "0.3.2", + "uglify-js" : "1.2.5", + "formidable" : "1.0.9", + "log4js" : "0.5.x", + "jsdom-nocontextifiy" : "0.2.10", + "async-stacktrace" : "0.0.2", + "npm" : "1.1.x", + "npm-registry-client" : "0.2.10", + "ejs" : "0.6.1", + "graceful-fs" : "1.1.5", + "slide" : "1.1.3", + "semver" : "1.0.13", + "security" : "1.0.0", + "tinycon" : "0.0.1", + "underscore" : "1.3.1", + "unorm" : "1.0.0", + "languages4translatewiki" : "0.1.2" }, "bin": { "etherpad-lite": "./node/server.js" }, "devDependencies": { From 1cc0e8cbf0d38b4a34674623e329cf9e2379c209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Eixarch?= Date: Wed, 28 Nov 2012 03:27:09 +0100 Subject: [PATCH 2/6] Restore original ini file --- src/locales/zh-hant.ini | 78 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/locales/zh-hant.ini diff --git a/src/locales/zh-hant.ini b/src/locales/zh-hant.ini new file mode 100644 index 00000000..b76ae180 --- /dev/null +++ b/src/locales/zh-hant.ini @@ -0,0 +1,78 @@ +; Exported from translatewiki.net +; Author: Simon Shek +[zh-hant] +index.newPad = 新Pad +index.createOpenPad = 或創建/開啟以下名稱的pad: +pad.toolbar.bold.title = 粗體(Ctrl-B) +pad.toolbar.italic.title = 斜體(Ctrl-I) +pad.toolbar.underline.title = 底線(Ctrl-U) +pad.toolbar.strikethrough.title = 刪除線 +pad.toolbar.ol.title = 有序清單 +pad.toolbar.ul.title = 無序清單 +pad.toolbar.indent.title = 縮排 +pad.toolbar.unindent.title = 凸排 +pad.toolbar.undo.title = 撤銷(Ctrl-Z) +pad.toolbar.redo.title = 重做(Ctrl-Y) +pad.toolbar.clearAuthorship.title = 清除作名顏色 +pad.toolbar.import_export.title = 以其他檔案格式導入/匯出 +pad.toolbar.timeslider.title = 時間軸 +pad.toolbar.savedRevision.title = 已儲存的修訂 +pad.toolbar.settings.title = 設定 +pad.toolbar.embed.title = 嵌入此pad +pad.toolbar.showusers.title = 顯示此pad的用戶 +pad.colorpicker.save = 儲存 +pad.colorpicker.cancel = 取消 +pad.loading = 載入中... +pad.settings.padSettings = Pad設定 +pad.settings.myView = 我的視窗 +pad.settings.stickychat = 永遠在屏幕上顯示聊天 +pad.settings.colorcheck = 作者顏色 +pad.settings.linenocheck = 行號 +pad.settings.fontType = 字體類型: +pad.settings.fontType.normal = 正常 +pad.settings.fontType.monospaced = 等寬 +pad.settings.globalView = 所有人的視窗 +pad.settings.language = 語言: +pad.importExport.import_export = 導入/匯出 +pad.importExport.import = 上載任何文字檔或文檔 +pad.importExport.successful = 完成! +pad.importExport.export = 匯出當前pad為: +pad.importExport.exporthtml = HTML +pad.importExport.exportplain = 純文字 +pad.importExport.exportword = Microsoft Word +pad.importExport.exportpdf = PDF +pad.importExport.exportopen = ODF(開放文件格式) +pad.importExport.exportdokuwiki = DokuWiki +pad.modals.connected = 已連線。 +pad.modals.reconnecting = 重新連接到您的pad... +pad.modals.forcereconnect = 強制重新連線 +pad.modals.uderdup = 在另一個視窗中開啟 +pad.modals.userdup.explanation = 此pad似乎在此電腦上的多個瀏覽器視窗中開啟。 +pad.modals.userdup.advice = 重新連接到此視窗。 +pad.modals.unauth = 未授權 +pad.modals.unauth.explanation = 您的權限在查看此頁時發生更改。請嘗試重新連接。 +pad.modals.looping = 已離線。 +pad.modals.looping.explanation = 與同步伺服器間有通信問題。 +pad.modals.looping.cause = 也許您通過一個不相容的防火牆或代理伺服器連接。 +pad.modals.initsocketfail = 無法訪問伺服器。 +pad.modals.initsocketfail.explanation = 無法連接到同步伺服器。 +pad.modals.initsocketfail.cause = 可能是由於您的瀏覽器或您的互聯網連接的問題。 +pad.modals.slowcommit = 已離線。 +pad.modals.slowcommit.explanation = 伺服器沒有回應。 +pad.modals.slowcommit.cause = 可能是由於網路連接問題。 +pad.modals.deleted = 已刪除。 +pad.modals.deleted.explanation = 此pad已被移除。 +pad.modals.disconnected = 您已中斷連線。 +pad.modals.disconnected.explanation = 伺服器連接曾中斷 +pad.modals.disconnected.cause = 伺服器可能無法使用。若此情況持續發生,請通知我們。 +pad.share = 分享此pad +pad.share.readonly = 唯讀 +pad.share.link = 連結 +pad.share.emebdcode = 嵌入網址 +pad.chat = 聊天 +pad.chat.title = 打開此pad的聊天。 +timeslider.pageTitle = {{appTitle}}時間軸 +timeslider.toolbar.returnbutton = 返回到pad +timeslider.toolbar.authors = 作者: +timeslider.toolbar.authorsList = 無作者 +timeslider.exportCurrent = 匯出當前版本為: From 9ec8a6e3d38bde94a3bc52daa16bb1588157f67c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Eixarch?= Date: Wed, 28 Nov 2012 04:02:55 +0100 Subject: [PATCH 3/6] back to globalize... don't work :S --- src/node/hooks/i18n.js | 11 +++++++---- src/package.json | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/node/hooks/i18n.js b/src/node/hooks/i18n.js index f6f0f8c8..147ef533 100644 --- a/src/node/hooks/i18n.js +++ b/src/node/hooks/i18n.js @@ -1,4 +1,4 @@ -var languages = require('languages4translatewiki') +var Globalize = require('globalize') , fs = require('fs') , path = require('path') , express = require('express') @@ -9,7 +9,8 @@ var localesPath = __dirname+"/../../locales"; var localeIndex = fs.readFileSync(localesPath+'/en.ini')+'\r\n'; // add language base 'en' to availableLangs -exports.availableLangs = {en: {name:'English',nativeName:'English',direction:'ltr'}}; +exports.availableLangs = {}; +exports.availableLangs['en'] = Globalize.cultures['en']; fs.readdir(localesPath, function(er, files) { files.forEach(function(locale) { @@ -19,11 +20,13 @@ fs.readdir(localesPath, function(er, files) { // build locale index localeIndex += '['+locale+']\r\n@import url(locales/'+locale+'.ini)\r\n' - // add info language {name, nativeName, direction} to availableLangs - exports.availableLangs[locale]=languages.getLanguageInfo(locale); + require('globalize/lib/cultures/globalize.culture.'+locale+'.js') + exports.availableLangs[locale]=Globalize.cultures[locale]; }) }) +console.log(exports.availableLangs); + exports.expressCreateServer = function(n, args) { args.app.use('/locales', express.static(localesPath)); diff --git a/src/package.json b/src/package.json index 24bcdd84..2bc5ac22 100644 --- a/src/package.json +++ b/src/package.json @@ -36,7 +36,7 @@ "tinycon" : "0.0.1", "underscore" : "1.3.1", "unorm" : "1.0.0", - "languages4translatewiki" : "0.1.2" + "globalize" : "0.1.1" }, "bin": { "etherpad-lite": "./node/server.js" }, "devDependencies": { From 795a20b3f24b122acc356e6ecd29b76a6cd09bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Eixarch?= Date: Wed, 28 Nov 2012 23:54:23 +0100 Subject: [PATCH 4/6] get languages availables through translatewiki API --- src/node/hooks/i18n.js | 47 ++++++++++++++++++++++++++++-------------- src/package.json | 3 +-- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/node/hooks/i18n.js b/src/node/hooks/i18n.js index 147ef533..3589dfb2 100644 --- a/src/node/hooks/i18n.js +++ b/src/node/hooks/i18n.js @@ -1,4 +1,4 @@ -var Globalize = require('globalize') +var http = require ('http') , fs = require('fs') , path = require('path') , express = require('express') @@ -8,24 +8,39 @@ var localesPath = __dirname+"/../../locales"; // Serve English strings directly with /locales.ini var localeIndex = fs.readFileSync(localesPath+'/en.ini')+'\r\n'; -// add language base 'en' to availableLangs -exports.availableLangs = {}; -exports.availableLangs['en'] = Globalize.cultures['en']; +exports.availableLangs = {'en': {'nativeName': 'English'}}; -fs.readdir(localesPath, function(er, files) { - files.forEach(function(locale) { - locale = locale.split('.')[0] - if(locale.toLowerCase() == 'en') return; +// build availableLangs with translatewiki web API +var request = http.request ('http://translatewiki.net/w/api.php?action=query&meta=siteinfo&siprop=languages&format=json', + function (res) { + var twLangs = ''; + res.setEncoding ('utf8'); + res.on ('data', function (chunk) { twLangs += chunk; }); + res.on ('end', function () { + // twLangs = [{code: 'en', '*': 'English'}...] + twLangs = JSON.parse(twLangs)['query']['languages']; - // build locale index - localeIndex += '['+locale+']\r\n@import url(locales/'+locale+'.ini)\r\n' + fs.readdir(localesPath, function(er, files) { + files.forEach(function(locale) { + locale = locale.split('.')[0]; + if(locale.toLowerCase() == 'en') return; + + // build locale index + localeIndex += '['+locale+']\r\n@import url(locales/'+locale+'.ini)\r\n'; - require('globalize/lib/cultures/globalize.culture.'+locale+'.js') - exports.availableLangs[locale]=Globalize.cultures[locale]; - }) -}) - -console.log(exports.availableLangs); + for (var l = 0; l < twLangs.length; l++) { + var code = twLangs[l]['code']; + if (locale == code) { + var nativeName = twLangs[l]['*']; + exports.availableLangs[code] = {'nativeName': nativeName}; + } + } + }); + }); + }); + }).on ('error', function(e) { + console.error('While query translatewiki API: '+e.message); + }).end(); exports.expressCreateServer = function(n, args) { diff --git a/src/package.json b/src/package.json index 2bc5ac22..e6805353 100644 --- a/src/package.json +++ b/src/package.json @@ -35,8 +35,7 @@ "security" : "1.0.0", "tinycon" : "0.0.1", "underscore" : "1.3.1", - "unorm" : "1.0.0", - "globalize" : "0.1.1" + "unorm" : "1.0.0" }, "bin": { "etherpad-lite": "./node/server.js" }, "devDependencies": { From 5f949b8457154d5b75a79765565977e8cbdf1e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Eixarch?= Date: Tue, 4 Dec 2012 12:12:58 +0100 Subject: [PATCH 5/6] Update language4translatewiki 0.1.3 --- src/node/hooks/i18n.js | 43 +++++++++++++----------------------------- src/package.json | 3 ++- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/node/hooks/i18n.js b/src/node/hooks/i18n.js index 3589dfb2..882e5156 100644 --- a/src/node/hooks/i18n.js +++ b/src/node/hooks/i18n.js @@ -1,4 +1,4 @@ -var http = require ('http') +var languages = require('languages4translatewiki') , fs = require('fs') , path = require('path') , express = require('express') @@ -10,37 +10,20 @@ var localeIndex = fs.readFileSync(localesPath+'/en.ini')+'\r\n'; exports.availableLangs = {'en': {'nativeName': 'English'}}; -// build availableLangs with translatewiki web API -var request = http.request ('http://translatewiki.net/w/api.php?action=query&meta=siteinfo&siprop=languages&format=json', - function (res) { - var twLangs = ''; - res.setEncoding ('utf8'); - res.on ('data', function (chunk) { twLangs += chunk; }); - res.on ('end', function () { - // twLangs = [{code: 'en', '*': 'English'}...] - twLangs = JSON.parse(twLangs)['query']['languages']; +fs.readdir(localesPath, function(er, files) { + files.forEach(function(locale) { + var ext = path.extname(locale); + locale = path.basename(locale, ext).toLowerCase(); + if(locale == 'en' || ext != '.ini') return; - fs.readdir(localesPath, function(er, files) { - files.forEach(function(locale) { - locale = locale.split('.')[0]; - if(locale.toLowerCase() == 'en') return; - - // build locale index - localeIndex += '['+locale+']\r\n@import url(locales/'+locale+'.ini)\r\n'; + // build locale index + localeIndex += '['+locale+']\r\n@import url(locales/'+locale+'.ini)\r\n' - for (var l = 0; l < twLangs.length; l++) { - var code = twLangs[l]['code']; - if (locale == code) { - var nativeName = twLangs[l]['*']; - exports.availableLangs[code] = {'nativeName': nativeName}; - } - } - }); - }); - }); - }).on ('error', function(e) { - console.error('While query translatewiki API: '+e.message); - }).end(); + // add info language {nativeName, direction} to availableLangs + exports.availableLangs[locale]=languages.getLanguageInfo(locale); + }) +}) + exports.expressCreateServer = function(n, args) { diff --git a/src/package.json b/src/package.json index e6805353..d2b03a97 100644 --- a/src/package.json +++ b/src/package.json @@ -35,7 +35,8 @@ "security" : "1.0.0", "tinycon" : "0.0.1", "underscore" : "1.3.1", - "unorm" : "1.0.0" + "unorm" : "1.0.0", + "languages4translatewiki" : "0.1.3" }, "bin": { "etherpad-lite": "./node/server.js" }, "devDependencies": { From a2b22652ceee934682f84bffa43d3b6d0df27fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Eixarch?= Date: Tue, 4 Dec 2012 13:02:23 +0100 Subject: [PATCH 6/6] added direction language in English --- src/node/hooks/i18n.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/hooks/i18n.js b/src/node/hooks/i18n.js index 882e5156..a45d46fe 100644 --- a/src/node/hooks/i18n.js +++ b/src/node/hooks/i18n.js @@ -8,7 +8,7 @@ var localesPath = __dirname+"/../../locales"; // Serve English strings directly with /locales.ini var localeIndex = fs.readFileSync(localesPath+'/en.ini')+'\r\n'; -exports.availableLangs = {'en': {'nativeName': 'English'}}; +exports.availableLangs = {'en': {'nativeName': 'English', 'direction': 'ltr'}}; fs.readdir(localesPath, function(er, files) { files.forEach(function(locale) {