[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linterna-magica-commit] [34] Final fix for bugs #32740.
From: |
Ivaylo Valkov |
Subject: |
[linterna-magica-commit] [34] Final fix for bugs #32740. |
Date: |
Wed, 06 Apr 2011 11:40:49 +0000 |
Revision: 34
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=34
Author: valkov
Date: 2011-04-06 11:40:48 +0000 (Wed, 06 Apr 2011)
Log Message:
-----------
Final fix for bugs #32740. Closes tasks #11056.
Ticket Links:
:-----------
http://savannah.gnu.org/task/?11056
http://savannah.gnu.org/bugs/?32740
Modified Paths:
--------------
trunk/HELP
trunk/HELP.bg
trunk/Makefile
trunk/data/style/template.css
trunk/src/lm_about.js
trunk/src/lm_check_for_updates.js
trunk/src/lm_config_options.js
trunk/src/lm_constructors.js
trunk/src/lm_create_video_object.js
trunk/src/lm_detect_object_in_remote_site.js
trunk/src/lm_init_options.js
trunk/src/lm_interface_player_web_buttons.js
trunk/src/lm_interface_toggle_plugin.js
trunk/src/lm_localisation.js
trunk/src/lm_log.js
trunk/src/lm_player_button_functions.js
trunk/src/lm_run.js
trunk/src/lm_site_youtube.js
Added Paths:
-----------
trunk/locale/
trunk/locale/linternamagica_l10n_bg_BG.user.js
Modified: trunk/HELP
===================================================================
--- trunk/HELP 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/HELP 2011-04-06 11:40:48 UTC (rev 34)
@@ -14,6 +14,7 @@
"priority": "self",
"autostart": "off",
"controls": "self",
+ "locale": "auto",
"cookies": "restore",
"wait_dm": "off",
};
@@ -63,6 +64,16 @@
Use controls provided by Linterna Mágica (default)
plugin
Use controls provided by the video plugin.
+ locale
+ Interface language
+ auto
+ Use the language of the browser interface if translation
+ is available (default)
+ <lc>_<CC>
+ Set language to lc_CC, where
+ <lc>: language code (lowercase)
+ <CC>: country code (uppercase)
+ Example: en_US, en_UK, bg_BG
cookies
The way cookies are processed. Please ***read*** "A note on
cookies", few lines below.
@@ -108,6 +119,16 @@
without timeout. If you have problems with Dailymotion increase the
value for the "wait_dm" option.
+Localisation
+
+Since version 0.0.10 the translations are split from the main
+userscript. Every localisation is a separate userscript in the locale
+directory with special structure. If there is translation for your
+language and you want to use it, you will have to install the
+userscript for it. By default Linterna Mágica tries to use the
+language of the browser interface if available. You could also set a
+custom locale by the "locale" config option.
+
Stop execution on every site
By default Linterna Mágica will run on every site. This is something
Modified: trunk/HELP.bg
===================================================================
--- trunk/HELP.bg 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/HELP.bg 2011-04-06 11:40:48 UTC (rev 34)
@@ -13,6 +13,7 @@
"priority": "self",
"autostart": "off",
"controls": "self",
+ "locale": "auto",
"cookies": "restore",
"wait_dm": "off",
};
@@ -64,6 +65,16 @@
Използване на бутоните на Linterna Mágica (стандартно)
plugin
Използване на бутоните на приставката за видео клипове.
+ locale
+ Език на интерфейса
+ auto
+ Да се използва езикът на браузъра, ако има наличен превод
+ (стандартно)
+ <lc>_<CC>
+ Да се използва език lc_CC, където
+ <lc>: код на езика (малки букви)
+ <CC>: код на държавата (главни букви)
+ Пример: en_US, en_UK, bg_BG
cookies
Начинът, по който да се обработват бисквитки. ***Прочетете***
„Бележка относно бисквитките“, няколко реда по-долу.
@@ -113,7 +124,17 @@
работеше без изчакване. Ако имате проблеми с Dailymotion, увеличете
стойността на "wait_dm".
+Превод на интерфейса
+От версия 0.0.10 нататък преводите са разделени от основния
+потребителски скрипт в самостоятелни файлове. Преводите са отделни
+потребителски скриптове със специална структура и се намират в папката
+locale. Ако съществува превод за вашият език и желаете да го
+използвате, трябва да инсталирате потребителския скрипт за
+него. Стандартно Linterna Mágica се опитва да използва езикът на
+интерфейса на браузъра, ако е преводът е наличен. Също така, можете да
+използвате превод по Ваш избор, чрез настройката "locale".
+
Спиране на изпълнението на всяка страница
Стандартно Linterna Mágica се изпълнява на всяка страница. Възможно е
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/Makefile 2011-04-06 11:40:48 UTC (rev 34)
@@ -53,8 +53,7 @@
USRSCRIPTHDR=$(srcdir)/lm_userscript_header.txt
FIRSTJSFILES="$(srcdir)/lm_init_options.js \
-$(srcdir)/lm_localisation.js $(srcdir)/lm_constructors.js \
-$(srcdir)/lm_config_options.js"
+$(srcdir)/lm_constructors.js $(srcdir)/lm_config_options.js"
LASTJSFILES="$(srcdir)/lm_run.js"
Modified: trunk/data/style/template.css
===================================================================
--- trunk/data/style/template.css 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/data/style/template.css 2011-04-06 11:40:48 UTC (rev 34)
@@ -32,10 +32,6 @@
/* Fix header buttons displacement in boozho.com */
/* Fixes entire interface displacement */
clear: left !important;
- /* Temporary fix for languages written from right to left. */
- /* If translation for language with RTL is present this breaks */
- /* See bug https://savannah.nongnu.org/bugs/?32740 */
- direction: ltr !important;
}
/* The message paragraph in the object */
Added: trunk/locale/linternamagica_l10n_bg_BG.user.js
===================================================================
--- trunk/locale/linternamagica_l10n_bg_BG.user.js
(rev 0)
+++ trunk/locale/linternamagica_l10n_bg_BG.user.js 2011-04-06 11:40:48 UTC
(rev 34)
@@ -0,0 +1,163 @@
+// @licstart The following is the entire license notice for the
+// JavaScript code in this page (or file).
+//
+// This file is part of Linterna Mágica
+//
+// Copyright (C) 2010, 2011 Ivaylo Valkov <address@hidden>
+// Copyright (C) 2010 Anton Katsarov <address@hidden>
+//
+// The JavaScript code in this page (or file) is free software: you
+// can redistribute it and/or modify it under the terms of the GNU
+// General Public License (GNU GPL) as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option)
+// any later version. The code is distributed WITHOUT ANY WARRANTY
+// without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
+//
+// As additional permission under GNU GPL version 3 section 7, you
+// may distribute non-source (e.g., minimized or compacted) forms of
+// that code without the copy of the GNU GPL normally required by
+// section 4, provided you include this license notice and a URL
+// through which recipients can access the Corresponding Source.
+//
+// @licend The above is the entire license notice for the JavaScript
+// code in this page (or file).
+//
+// @source http://e-valkov.org/linterna-magica
+
+// ==UserScript==
+// @name Linterna Mágica l10n bg_BG
+// @namespace Linterna Mágica
+// @description Bulgarian localisation for Linterna Mágica.
+// @include http://*
+// @include https://*
+
+// ==/UserScript==
+
+var LM_L10N =
+ {
+ "bg_BG":
+ {
+ __translators: ["Ивайло Вълков <address@hidden>",],
+ __direction: "ltr",
+ "Translation": "Превод",
+ "Download": "Запазване",
+ "Save the video clip": "Запазване на видео клипа",
+ "Loading video...": "Зареждане на клипа…",
+ "Plugin": "Приставка",
+ "Switch between flash plugin and Linterna Mágica":
+ "Превключване между приставката за флаш и Linterna Mágica",
+ "Waiting for video plugin...":
+ "Изчакване на приставката за видео клипове…",
+ "About": "Относно",
+ "Linterna Mágica Home page":
+ "Уеб страница на Linterna Mágica",
+ "Stop": "Спиране",
+ "Play": "Изпълнение",
+ "Pause": "Пауза",
+ "Time": "Време",
+ "Volume control": "Сила на звука",
+ "Mute": "Заглушаване",
+ "Muted": "Заглушен",
+ "Unmute": "Премахване на заглушаването",
+ "Fullscreen": "На цял екран",
+ "Loading": "Зареждане",
+ "Buffering": "Буфериране",
+ "Higher quality": "Високо качество",
+ " version: ": " версия: ",
+ "This program is free software; ":
+ "Тази програма е свободен софтуер. ",
+ "you can redistribute it and/or ":
+ "Можете да я разпространявате и/или ",
+ "modify it under the terms of the ":
+ "променяте под условията на ",
+ "GNU General Public License (GNU GPL)":
+ "Общия публичен лиценз на GNU (GNU GPL)",
+ " version 3 (or later). ":
+ " — версия 3 на лиценза или по-късна. ",
+ "A copy of the license can be downloaded from ":
+ "Копие на лиценза можете да изтеглите от ",
+ "Watch video on the web ": "Гледайте уеб видео клипове ",
+ "in a brand new way: ":"по напълно нов начин: ",
+ "You don't need a glint, ":"Нямате нужда от проблясъци, ",
+ "the magic lantern is ignited!":"вълшебният фенер е разпален!",
+ "New version": "Нова версия",
+ "Date":"Дата",
+ "Update": "Обновление",
+ "Jan": "яну",
+ "Feb": "фев",
+ "Mar": "мар",
+ "Apr": "апр",
+ "May": "май",
+ "Jun": "юни",
+ "Jul": "юли",
+ "Aug": "авг",
+ "Sep": "сеп",
+ "Oct": "окт",
+ "Noe": "ное",
+ "Dec": "дек",
+ "New version is available.":"Налична е нова версия.",
+ "released at":"публикувана на",
+ "Read the news section at the home page":
+ "Прочетете новините на уеб страницата",
+ "Linterna Mágica error and debug messages":
+ "Съобщения за отстраняване на грешки в Linterna Mágica",
+ "Debug messages": "Отстраняване на грешки",
+ "Remove log": "Премахване на обекта",
+ "Show/hide debug messages":
+ "Показване/скриване на съобщенията за отстраняване на грешки",
+ "Watch this video at it's original site with Linterna Mágica":
+ "Гледайте този видео клип на неговата уеб страница с Linterna
Mágica",
+ },
+ };
+
+// Do NOT edit past this line.
+
+var head = document.getElementsByTagName("head")[0];
+var script = document.createElement("script");
+
+script.setAttribute("type", "text/javascript");
+
+var script_data =
+ "if (window.LinternaMagica_L10N == undefined)"+
+ "{"+
+ "window.LinternaMagica_L10N = new Object();"+
+ "}; ";
+
+for (var o in LM_L10N)
+{
+ script_data += "window.LinternaMagica_L10N['"+o+ "'] = ";
+ if (typeof(LM_L10N[o]) == 'object')
+ {
+ script_data += "{";
+ for (var oo in LM_L10N[o])
+ {
+ if (oo == "__translators" &&
+ typeof(LM_L10N[o][oo]) == "object")
+ {
+ console.log("DIBIBIBI ");
+ script_data += '"'+oo+ '" : ["' +
+ LM_L10N[o][oo].join('","')+'"],';
+ }
+ else
+ {
+ // String or number
+ script_data += '"'+oo+ '" : "' +LM_L10N[o][oo]+'",';
+ }
+ }
+ script_data += "};";
+ }
+ else
+ {
+ script_data += '"'+LM_L10N[o]+'"';
+ }
+}
+
+script_data += ";";
+
+script.textContent = script_data;
+
+head.appendChild(script);
+
+head.removeChild(script);
+LM_L10N = undefined;
Modified: trunk/src/lm_about.js
===================================================================
--- trunk/src/lm_about.js 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/src/lm_about.js 2011-04-06 11:40:48 UTC (rev 34)
@@ -37,7 +37,7 @@
var p = document.createElement("p");
var text = document.createTextNode(
- this.name+_(" version: ")+this.version);
+ this.name+this._(" version: ")+this.version);
p.appendChild(text);
box.appendChild(p);
@@ -50,15 +50,44 @@
box.appendChild(p);
}
+ // Translators
+ if (this.languages[this.lang] &&
+ this.languages[this.lang].__translators)
+ {
+ var transl = null;
+ if (typeof (this.languages[this.lang].__translators) == "object")
+ {
+ transl = this.languages[this.lang].__translators;
+ }
+ else
+ {
+ transl = new Array();
+ transl.push(this.languages[this.lang].__translators);
+ }
+
+ p = document.createElement("p");
+ text = document.createTextNode(this._("Translation")+":");
+ p.appendChild(text);
+ box.appendChild(p);
+
+ for (var l=0, length=transl.length; l< length; l++)
+ {
+ p = document.createElement("p");
+ text = document.createTextNode(transl[l]);
+ p.appendChild(text);
+ box.appendChild(p);
+ }
+ }
+
// Info
p = document.createElement("p");
- text = document.createTextNode(this.description);
+ text = document.createTextNode(this.description());
p.appendChild(text);
box.appendChild(p);
// License
p = document.createElement("p");
- text = document.createTextNode(this.license);
+ text = document.createTextNode(this.license());
p.appendChild(text);
box.appendChild(p);
@@ -70,7 +99,7 @@
box.appendChild(p);
var homepage = this.pack_external_link(this.homepage,
- _("Linterna Mágica Home page"));
+ this._("Linterna Mágica Home page"));
p = document.createElement('p');
p.appendChild(homepage);
Modified: trunk/src/lm_check_for_updates.js
===================================================================
--- trunk/src/lm_check_for_updates.js 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/src/lm_check_for_updates.js 2011-04-06 11:40:48 UTC (rev 34)
@@ -246,9 +246,9 @@
var format_date = this.updates_data.format_date;
var title =
- _("New version")+
- ": "+version+". "+_("Date")+": "+_(format_date[2]) + " "+
- _(format_date[1]) + " " + _(format_date[3]);
+ this._("New version")+
+ ": "+version+". "+this._("Date")+": "+this._(format_date[2]) + " "+
+ this._(format_date[1]) + " " + this._(format_date[3]);
var notifier = document.createElement("a");
@@ -257,7 +257,7 @@
notifier.setAttribute("class", "linterna-magica-update-notifier-link ");
notifier.setAttribute("id", "linterna-magica-update-"+
"notifier-link-"+id);
- notifier.textContent = _("Update");
+ notifier.textContent = this._("Update");
return notifier;
}
@@ -277,21 +277,21 @@
// Other
var p = document.createElement('p');
- var t = document.createTextNode(_("New version is available."));
+ var t = document.createTextNode(this._("New version is available."));
p.appendChild(t);
div.appendChild(p);
p = document.createElement('p');
t = document.createTextNode(
"Linterna Mágica"+" "+version+
- " "+_("released at")+" "+_(format_date[2]) + " "+
- _(format_date[1]) + " "+_(format_date[3]));
+ " "+this._("released at")+" "+this._(format_date[2]) + " "+
+ this._(format_date[1]) + " "+this._(format_date[3]));
p.appendChild(t);
div.appendChild(p);
var a = this.pack_external_link(
this.homepage+"/#news",
- _("Read the news section at the home page"));
+ this._("Read the news section at the home page"));
p = document.createElement('p');
p.appendChild(a);
Modified: trunk/src/lm_config_options.js
===================================================================
--- trunk/src/lm_config_options.js 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/src/lm_config_options.js 2011-04-06 11:40:48 UTC (rev 34)
@@ -188,3 +188,36 @@
this.updates = set_updates_to;
}
+
+// Set the language to the user preferred or the env (provided by the
+// browser)
+LinternaMagica.prototype.set_locale = function(locale)
+{
+ // See lm_localisation.js
+ this.set_env_lang();
+
+ // In case the country code is lowercase and the language code is
+ // upper case
+ if (/.*_.*/.test(locale))
+ {
+ locale = locale.split(/_/);
+ locale[locale.length-1] =
+ locale[locale.length-1].toUpperCase();
+
+ locale[0] =
+ locale[0].toLowerCase();
+
+ locale = locale.join("_");
+ }
+
+ var set_lang_to = locale ? locale : this.env_lang;
+
+ if (!set_lang_to ||
+ !/[a-z][a-z]_[A-Z][A-Z]/i.test(set_lang_to) ||
+ this.languages[set_lang_to] == undefined)
+ {
+ set_lang_to = "C";
+ }
+
+ this.lang = set_lang_to;
+}
Modified: trunk/src/lm_constructors.js
===================================================================
--- trunk/src/lm_constructors.js 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/src/lm_constructors.js 2011-04-06 11:40:48 UTC (rev 34)
@@ -60,6 +60,8 @@
// element. Otherwise it is created and visible in iframes and
// objects that are used to embed clips in remote sites.
+ this.set_locale(params.locale);
+
// Could be a string, but we need integer.
this.debug_level = parseInt(params.debug);
@@ -207,19 +209,29 @@
"http://e-valkov.org/linterna-magica/downloads/updates.js";
// "http://localhost/linterna-magica/downloads/updates.js";
-LinternaMagica.prototype.description =
- _("Watch video on the web ")+
- _("in a brand new way: ")+
- _("You don't need a glint, ")+
- _("the magic lantern is ignited!");
+// When this is a function the internal _() function could be used.
+LinternaMagica.prototype.description = function()
+{
+ return (
+ this._("Watch video on the web ")+
+ this._("in a brand new way: ")+
+ this._("You don't need a glint, ")+
+ this._("the magic lantern is ignited!")
+ );
+}
-LinternaMagica.prototype.license =
- _("This program is free software; ")+
- _("you can redistribute it and/or ")+
- _("modify it under the terms of the ")+
- _("GNU General Public License (GNU GPL)")+
- _(" version 3 (or later). ")+
- _("A copy of the license can be downloaded from ");
+// When this is a function the internal _() function could be used.
+LinternaMagica.prototype.license = function()
+{
+ return (
+ this._("This program is free software; ")+
+ this._("you can redistribute it and/or ")+
+ this._("modify it under the terms of the ")+
+ this._("GNU General Public License (GNU GPL)")+
+ this._(" version 3 (or later). ")+
+ this._("A copy of the license can be downloaded from ")
+ );
+}
LinternaMagica.prototype.license_link =
"http://www.gnu.org/licenses/gpl.html";
@@ -321,3 +333,13 @@
}, 800);
}
+
+// Localization languages object
+LinternaMagica.prototype.languages = new Object();
+
+// No translation.
+LinternaMagica.prototype.languages["C"] =
+ {
+ __direction: "ltr",
+ __translators: null,
+ };
Modified: trunk/src/lm_create_video_object.js
===================================================================
--- trunk/src/lm_create_video_object.js 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/src/lm_create_video_object.js 2011-04-06 11:40:48 UTC (rev 34)
@@ -69,10 +69,25 @@
container.setAttribute("id", "linterna-magica-"+id);
container.setAttribute("class", "linterna-magica");
+
+ // Fix for rtl languages. See
+ // https://savannah.nongnu.org/bugs/?32740
+ // https://savannah.nongnu.org/task/?11056
+ container.setAttribute("dir", this.languages[this.lang].__direction);
+
+ var lang_code = this.lang.split("_")[0];
+ if (!lang_code)
+ {
+ // The locale is C
+ lang_code = "en";
+ }
+
+ container.setAttribute("xml:lang", lang_code);
+ container.setAttribute("lang", lang_code);
+
container.style.setProperty("width",
(object_data.width+"px"), "important");
-
header.setAttribute("class", "linterna-magica-header");
header.setAttribute("id", "linterna-magica-header-"+id);
header.style.setProperty("width",
@@ -82,7 +97,7 @@
script_name.textContent = "Linterna Mágica";
script_name.setAttribute("href", "#");
- script_name.setAttribute("title", _("About")+ " Linterna Mágica");
+ script_name.setAttribute("title", this._("About")+ " Linterna Mágica");
script_name.setAttribute("id", "linterna-magica-logo-"+id);
script_name.setAttribute("class", "linterna-magica-logo");
@@ -100,8 +115,8 @@
header.appendChild(toggle_plugin);
}
- dw_link.textContent = _("Download");
- dw_link.setAttribute("title", _("Save the video clip"));
+ dw_link.textContent = this._("Download");
+ dw_link.setAttribute("title", this._("Save the video clip"));
dw_link.setAttribute("id", "linterna-magica-video-download-link-"+id);
dw_link.setAttribute("class", "linterna-magica-video-download-link");
@@ -120,8 +135,8 @@
var hd_wrapper = document.createElement("div");
var hd_button = document.createElement("a");
hd_button.setAttribute("href","#");
- hd_button.textContent = _("HQ");
- hd_button.setAttribute("title", _("Higher quality"));
+ hd_button.textContent = this._("HQ");
+ hd_button.setAttribute("title", this._("Higher quality"));
hd_button.setAttribute("class", "linterna-magica-switch-hd");
hd_button.addEventListener("click", function(ev)
{
@@ -182,7 +197,7 @@
object_tag.setAttribute("width", object_data.width);
object_tag.setAttribute("height", object_data.height);
object_tag.setAttribute("id","linterna-magica-video-object-"+id);
- object_tag.setAttribute("standby", _("Loading video..."));
+ object_tag.setAttribute("standby", this._("Loading video..."));
if (object_data.link)
{
@@ -191,7 +206,7 @@
object_tag.setAttribute("data", object_data.link);
}
- message.textContent = _("Waiting for video plugin...");
+ message.textContent = this._("Waiting for video plugin...");
param.setAttribute("name", "autoplay");
// Start only the first found clip
Modified: trunk/src/lm_detect_object_in_remote_site.js
===================================================================
--- trunk/src/lm_detect_object_in_remote_site.js 2011-04-05 10:22:41 UTC
(rev 33)
+++ trunk/src/lm_detect_object_in_remote_site.js 2011-04-06 11:40:48 UTC
(rev 34)
@@ -173,7 +173,7 @@
"Linterna Mágica >>");
a.setAttribute("class", "linterna-magica-toggle-plugin");
- a.setAttribute("title", _("Watch this video at it's original"+
+ a.setAttribute("title", this._("Watch this video at it's original"+
" site with Linterna Mágica"+
" ("+object_data.remote_site_link+")"));
Modified: trunk/src/lm_init_options.js
===================================================================
--- trunk/src/lm_init_options.js 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/src/lm_init_options.js 2011-04-06 11:40:48 UTC (rev 34)
@@ -61,6 +61,14 @@
// self: Use controls provided by Linterna Mágica (default)
// plugin: Use controls provided by the video plugin
"controls": "self",
+ // Interface language
+ // auto: Use the language of the browser interface if
+ // translation is available (default)
+ // <lc>_<CC>: Set language to lc_CC, where
+ // <lc>: language code (lowercase)
+ // <CC>: country code (uppercase)
+ // Example: en_US, en_UK, bg_BG
+ "locale": "auto",
// The way cookies are proccessed. The explanation is too long
// to fit here. Please ***read*** "A note on cookies", in the
// HELP file.
Modified: trunk/src/lm_interface_player_web_buttons.js
===================================================================
--- trunk/src/lm_interface_player_web_buttons.js 2011-04-05 10:22:41 UTC
(rev 33)
+++ trunk/src/lm_interface_player_web_buttons.js 2011-04-06 11:40:48 UTC
(rev 34)
@@ -41,7 +41,7 @@
play.setAttribute("class", "linterna-magica-controls-buttons "+
"linterna-magica-controls-buttons-play");
play.setAttribute("href", "#");
- play.setAttribute("title", _("Play"));
+ play.setAttribute("title", this._("Play"));
play.textContent ="Pl";
// Only pause button should be visible on autostart
// Auto start only the firs object in the page
@@ -77,7 +77,7 @@
pause.setAttribute("class", "linterna-magica-controls-buttons "+
"linterna-magica-controls-buttons-pause");
pause.setAttribute("href", "#");
- pause.setAttribute("title", _("Pause"));
+ pause.setAttribute("title", this._("Pause"));
pause.textContent ="Pa";
// Only play button should be visible if !autostart (and
if (!this.autostart || id !=0)
@@ -107,7 +107,7 @@
stop.setAttribute("class", "linterna-magica-controls-buttons "+
"linterna-magica-controls-buttons-stop");
stop.setAttribute("href", "#");
- stop.setAttribute("title", _("Stop"));
+ stop.setAttribute("title", this._("Stop"));
stop.textContent ="St";
stop.addEventListener("click", function(ev)
{
@@ -128,34 +128,8 @@
}, false);
controls.appendChild(stop);
-
- // var seek_b = document.createElement("a");
- // seek_b.setAttribute("class", "linterna-magica-controls-buttons");
- // seek_b.setAttribute("href", "#");
- // seek_b.setAttribute("title", _("Seek 10 seconds backwards"));
- // seek_b.textContent ="Rw";
- // seek_b.addEventListener("click", function(ev)
- // {
- // ev.preventDefault();
- // self.player.rewind.apply(self, [id]);
- // }, false);
- // controls.appendChild(seek_b);
-
- // var seek_f = document.createElement("a");
- // seek_f.setAttribute("class", "linterna-magica-controls-buttons");
- // seek_f.setAttribute("href", "#")
- // seek_f.setAttribute("title", _("Seek 10 seconds forward"));
- // seek_f.textContent ="Fw";
- // seek_f.addEventListener("click", function(ev)
- // {
- // ev.preventDefault();
- // self.player.forward.apply(self, [id]);
- // }, false);
- // controls.appendChild(seek_f);
-
-
var time_slider = document.createElement("div");
- time_slider.setAttribute("title", _("Time"));
+ time_slider.setAttribute("title", this._("Time"));
time_slider.setAttribute("class",
"linterna-magica-controls-horizontal-slider");
@@ -226,13 +200,24 @@
}, 500);
}, false);
+ var time_knob_move = null;
+ if (this.languages[this.lang].__direction == "ltr" ||
+ this.languages[this.lang].__direction !== "rtl")
+ {
+ time_knob_move = "left";
+ }
+ else if (this.languages[this.lang].__direction == "rtl")
+ {
+ time_knob_move = "right";
+ }
+
var time_knob = document.createElement("a");
- time_knob.setAttribute("title", _("Time"));
+ time_knob.setAttribute("title", this._("Time"));
time_knob.setAttribute("class", "linterna-magica-controls-slider-knob");
time_knob.setAttribute("id",
"linterna-magica-controls-time-slider-knob-"+id);
- time_knob.style.setProperty("left", "0px", "important");
+ time_knob.style.setProperty(time_knob_move, "0px", "important");
time_knob.setAttribute("href", "#");
time_knob.addEventListener("mousedown", function(ev)
@@ -267,7 +252,7 @@
var volume_slider = document.createElement("div");
volume_slider.setAttribute("class",
"linterna-magica-controls-horizontal-slider");
- volume_slider.setAttribute("title", _("Volume control"));
+ volume_slider.setAttribute("title", this._("Volume control"));
// The slider width is calculated from
// the object width. We have 6 buttons
@@ -307,6 +292,18 @@
volume_text.textContent = pos.val;
}, false);
+ var volume_knob_move = null;
+
+ if (this.languages[this.lang].__direction == "ltr" ||
+ this.languages[this.lang].__direction !== "rtl")
+ {
+ volume_knob_move = "left";
+ }
+ else if (this.languages[this.lang].__direction == "rtl")
+ {
+ volume_knob_move = "right";
+ }
+
var volume_knob = document.createElement("a");
volume_knob.setAttribute("class", "linterna-magica-controls-slider-knob");
volume_knob.setAttribute("id",
@@ -316,9 +313,9 @@
// volume_knob.style.setProperty("width",
// parseInt(volume_width*10/100)+"px",
// "important");
- volume_knob.style.setProperty("left", "0px", "important");
+ volume_knob.style.setProperty(volume_knob_move, "0px", "important");
volume_knob.setAttribute("href", "#");
- volume_knob.setAttribute("title", _("Volume control"));
+ volume_knob.setAttribute("title", this._("Volume control"));
volume_knob.addEventListener("mousedown", function(ev)
{
ev.preventDefault();
@@ -342,7 +339,7 @@
mute.setAttribute("class", "linterna-magica-controls-buttons "+
"linterna-magica-controls-buttons-mute");
mute.setAttribute("href", "#");
- mute.setAttribute("title", _("Mute"));
+ mute.setAttribute("title", this._("Mute"));
mute.textContent ="M";
mute.addEventListener("click", function(ev)
@@ -354,7 +351,7 @@
if (/M/i.test(mute.textContent))
{
mute.textContent = "U";
- mute.setAttribute("title", _("Unmute"));
+ mute.setAttribute("title", this._("Unmute"));
mute.setAttribute(
"class",
@@ -363,16 +360,16 @@
"buttons-unmute");
volume_text.textContent = "0%";
volume_text.setAttribute("title",
- _("Muted"));
+ this._("Muted"));
volume_slider.setAttribute("title",
- _("Muted"));
+ this._("Muted"));
volume_knob.setAttribute("title",
- _("Muted"));
+ this._("Muted"));
}
else
{
mute.textContent = "M";
- mute.setAttribute("title", _("Mute"));
+ mute.setAttribute("title", this._("Mute"));
volume_text.textContent = volume;
volume_text.removeAttribute("title");
@@ -384,10 +381,10 @@
volume_slider.
setAttribute("title",
- _("Volume control"));
+ this._("Volume control"));
volume_knob.
setAttribute("title",
- _("Volume control"));
+ this._("Volume control"));
}
@@ -399,7 +396,7 @@
"class", "linterna-magica-controls-buttons "+
"linterna-magica-controls-buttons-fullscreen");
fullscreen.setAttribute("href", "#");
- fullscreen.setAttribute("title", _("Fullscreen"));
+ fullscreen.setAttribute("title", this._("Fullscreen"));
fullscreen.textContent ="Fs";
fullscreen.addEventListener("click", function(ev)
{
Modified: trunk/src/lm_interface_toggle_plugin.js
===================================================================
--- trunk/src/lm_interface_toggle_plugin.js 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/src/lm_interface_toggle_plugin.js 2011-04-06 11:40:48 UTC (rev 34)
@@ -57,7 +57,7 @@
}
else
{
- toggle_plugin.textContent = _("Plugin");
+ toggle_plugin.textContent = this._("Plugin");
toggle_plugin.setAttribute("class",
"linterna-magica-toggle-plugin-header");
toggle_plugin.setAttribute("id",
@@ -65,7 +65,7 @@
}
toggle_plugin.setAttribute("title",
- _("Switch between flash plugin"+
+ this._("Switch between flash plugin"+
" and Linterna Mágica"));
return wrapper ? wrapper : toggle_plugin;
Modified: trunk/src/lm_localisation.js
===================================================================
--- trunk/src/lm_localisation.js 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/src/lm_localisation.js 2011-04-06 11:40:48 UTC (rev 34)
@@ -27,89 +27,46 @@
// END OF LICENSE HEADER
-// Localization
-var languages =
+// Localization function
+// Checks if there is translation for the default browser language or
+// user selected one and then if the string is translated into that
+// language. If no translation is found the string is returned as-is
+// (English);
+LinternaMagica.prototype._ = function (string)
+{
+ if (this.lang == "C")
{
- "bg":
- {
- "Download": "Запазване",
- "Save the video clip": "Запазване на видео клипа",
- "Loading video...": "Зареждане на клипа…",
- "Plugin": "Приставка",
- "Switch between flash plugin and Linterna Mágica":
- "Превключване между приставката за флаш и Linterna Mágica",
- "Waiting for video plugin...":
- "Изчакване на приставката за видео клипове…",
- "About": "Относно",
- "Linterna Mágica Home page":
- "Уеб страница на Linterna Mágica",
- "Stop": "Спиране",
- "Play": "Изпълнение",
- "Pause": "Пауза",
- "Time": "Време",
- "Volume control": "Сила на звука",
- "Mute": "Заглушаване",
- "Muted": "Заглушен",
- "Unmute": "Премахване на заглушаването",
- "Fullscreen": "На цял екран",
- "Loading": "Зареждане",
- "Buffering": "Буфериране",
- "Higher quality": "Високо качество",
- " version: ": " версия: ",
- "This program is free software; ":
- "Тази програма е свободен софтуер. ",
- "you can redistribute it and/or ":
- "Можете да я разпространявате и/или ",
- "modify it under the terms of the ":
- "променяте под условията на ",
- "GNU General Public License (GNU GPL)":
- "Общия публичен лиценз на GNU (GNU GPL)",
- " version 3 (or later). ":
- " — версия 3 на лиценза или по-късна. ",
- "A copy of the license can be downloaded from ":
- "Копие на лиценза можете да изтеглите от ",
- "Watch video on the web ": "Гледайте уеб видео клипове ",
- "in a brand new way: ":"по напълно нов начин: ",
- "You don't need a glint, ":"Нямате нужда от проблясъци, ",
- "the magic lantern is ignited!":"вълшебният фенер е разпален!",
- "New version": "Нова версия",
- "Date":"Дата",
- "Update": "Обновление",
- "Jan": "яну",
- "Feb": "фев",
- "Mar": "мар",
- "Apr": "апр",
- "May": "май",
- "Jun": "юни",
- "Jul": "юли",
- "Aug":"авг",
- "Sep": "сеп",
- "Oct": "окт",
- "Noe":"ное",
- "Dec":"дек",
- "New version is available.":"Налична е нова версия.",
- "released at":"публикувана на",
- "Read the news section at the home page":
- "Прочетете новините на уеб страницата",
- "Linterna Mágica error and debug messages":
- "Съобщения за отстраняване на грешки в Linterna Mágica",
- "Debug messages": "Отстраняване на грешки",
- "Remove log": "Премахване на обекта",
- "Show/hide debug messages":
- "Показване/скриване на съобщенията за отстраняване на грешки",
- "Watch this video at it's original site with Linterna Mágica":
- "Гледайте този видео клип на неговата уеб страница с Linterna
Mágica",
- },
- };
+ return string;
+ }
-// Localization function
-// Checks if there is translation for the default browser language and
-// then if the string is translated into that language. If no translation
-// is found the string is returned as-is (en);
-function _(string)
+ var use_lang = this.languages[this.lang];
+
+ return use_lang ?
+ use_lang[string] ? use_lang[string] : string : string ;
+}
+
+// Examines navigator.language and sets this.env_lang (en_US, en_UK,
+// bg_BG; etc)
+LinternaMagica.prototype.set_env_lang = function()
{
- var lang = navigator.language.substring(0,2);
+ var env_lang = navigator.language.replace("-", "_");
+
+ // Epiphany (WebKit?) without translation
+ if (env_lang.toLowerCase() == "c")
+ {
+ // Same as GNU IceCat & Firefox without translation
+ env_lang = "en_US";
+ }
+
+ // Epiphany uses only lowercase
+ env_lang = env_lang.split(/_/);
+ env_lang[env_lang.length-1] =
+ env_lang[env_lang.length-1].toUpperCase();
- return languages[lang] ? languages[lang][string] ?
- languages[lang][string] : string : string ;
+ env_lang[0] =
+ env_lang[0].toLowerCase();
+
+ env_lang = env_lang.join("_");
+
+ this.env_lang = env_lang;
}
Modified: trunk/src/lm_log.js
===================================================================
--- trunk/src/lm_log.js 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/src/lm_log.js 2011-04-06 11:40:48 UTC (rev 34)
@@ -135,7 +135,7 @@
var p = document.createElement("p");
- var txt = document.createTextNode(_(
+ var txt = document.createTextNode(this._(
"Linterna Mágica error and debug messages"));
p.appendChild(txt);
@@ -144,7 +144,7 @@
var close = document.createElement("a");
close.textContent="x";
close.setAttribute("href", "#");
- close.setAttribute("title", _("Remove log"));
+ close.setAttribute("title", this._("Remove log"));
p.appendChild(close);
close.addEventListener("click", function(ev)
@@ -159,7 +159,7 @@
var show_hide_log = document.createElement("a");
show_hide_log.textContent="-";
show_hide_log.setAttribute("href", "#");
- show_hide_log.setAttribute("title", _("Show/hide debug messages"));
+ show_hide_log.setAttribute("title", this._("Show/hide debug messages"));
show_hide_log.setAttribute("class",
"linterna-magica-web-log-show-hide-body");
p.appendChild(show_hide_log);
@@ -225,11 +225,11 @@
var log_link = document.createElement("a");
log_link.setAttribute("title",
- _("Linterna Mágica error and debug messages"));
+ this._("Linterna Mágica error and debug messages"));
log_link.setAttribute("href", "#");
log_link.setAttribute("class", "linterna-magica-web-log-link");
log_link.setAttribute("id", "linterna-magica-web-log-link-"+id);
- log_link.textContent = _("Debug messages");
+ log_link.textContent = this._("Debug messages");
return log_link;
}
Modified: trunk/src/lm_player_button_functions.js
===================================================================
--- trunk/src/lm_player_button_functions.js 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/src/lm_player_button_functions.js 2011-04-06 11:40:48 UTC (rev 34)
@@ -127,10 +127,10 @@
switch(video_object.playState)
{
case 0:
- time.state = _("Loading");
+ time.state = this._("Loading");
break;
case 6:
- time.state = _("Buffering");
+ time.state = this._("Buffering");
break;
}
@@ -164,10 +164,10 @@
switch (video_object.input.state)
{
case 0:
- time.state = _("Loading");
+ time.state = this._("Loading");
break;
case 2:
- time.state = _("Buffering");
+ time.state = this._("Buffering");
break;
}
}
@@ -201,7 +201,7 @@
// Xine supports only playing (3) and paused (4)
var state = video_object.controls.GetPlayState();
if (state !== 4 && state !== 3)
- time.state = _("Loading");
+ time.state = this._("Loading");
}
catch(e)
{
@@ -243,10 +243,10 @@
{
case "Loading":
case "Waiting":
- time.state = _("Loading");
+ time.state = this._("Loading");
break;
case "NOT_READY":
- time.state = _("Waiting plugin");
+ time.state = this._("Waiting plugin");
break;
}
@@ -662,7 +662,18 @@
if (!knob)
return null;
- var old_position = parseInt(knob.style.getPropertyValue("left"));
+ var move = null;
+ if (this.languages[this.lang].__direction == "ltr" ||
+ this.languages[this.lang].__direction !== "rtl")
+ {
+ move = "left";
+ }
+ else if (this.languages[this.lang].__direction == "rtl")
+ {
+ move = "right";
+ }
+
+ var old_position = parseInt(knob.style.getPropertyValue(move));
var direction = 0;
var position = old_position;
@@ -678,8 +689,6 @@
}
-
-
// Get wheel direction
if (event.type == "mousewheel")
{
@@ -715,6 +724,13 @@
offset_left-
knob.clientWidth/2;
+ // When the direction is rtl the knob starts at
+ // slider.clientWidth, and moves to 0.
+ if (move == "right")
+ {
+ position = Math.abs(position- slider.clientWidth);
+ }
+
if (position > old_position)
{
direction = 1;
@@ -765,12 +781,12 @@
position = 0;
}
- knob.style.setProperty("left",
+ knob.style.setProperty(move,
position +"px",
"important");
var return_data = new Object();
- return_data.val = (parseInt((position/slider.clientWidth) *100))+"%";
+ return_data.val = (parseInt((position/slider.clientWidth) *100))+"%";
return_data.direction = direction;
return return_data;
}
@@ -823,6 +839,18 @@
if (knob)
{
+ var move = null;
+
+ if (this.languages[this.lang].__direction == "ltr" ||
+ this.languages[this.lang].__direction !== "rtl")
+ {
+ move = "left";
+ }
+ else if (this.languages[this.lang].__direction == "rtl")
+ {
+ move = "right";
+ }
+
var slider = knob.parentNode;
var pos = parseInt(slider.clientWidth *
time_and_state.percent);
@@ -830,7 +858,7 @@
if (pos >= slider.clientWidth)
pos = slider.clientWidth - knob.clientWidth;;
- knob.style.setProperty("left",
+ knob.style.setProperty(move,
pos+"px",
"important");
}
Modified: trunk/src/lm_run.js
===================================================================
--- trunk/src/lm_run.js 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/src/lm_run.js 2011-04-06 11:40:48 UTC (rev 34)
@@ -55,7 +55,8 @@
// 1.5 second with 250 ms interval.
if (window.linterna_magica_init_counter >= 6 ||
- data_window.linterna_magica_user_config != undefined)
+ data_window.linterna_magica_user_config != undefined ||
+ data_window.LinternaMagica_L10N != undefined)
{
clearInterval(window.linterna_magica_init_timeout);
ready_to_init = 1;
@@ -78,6 +79,29 @@
}
}
+ delete data_window.linterna_magica_user_config;
+
+ for (var loc in data_window.LinternaMagica_L10N)
+ {
+ LinternaMagica.prototype.languages[loc] =
+ data_window.LinternaMagica_L10N[loc];
+
+ // Direction value must be lowercase
+ var dir = data_window.LinternaMagica_L10N[loc]["__direction"];
+
+ // Wrong value
+ if (dir != "rtl" &&
+ dir != "ltr")
+ {
+ dir = "ltr";
+ }
+
+ LinternaMagica.prototype.languages[loc]["__direction"] =
+ dir.toLowerCase();
+ }
+
+ delete data_window.LinternaMagica_L10N;
+
// Init
var larerna_magica = new LinternaMagica(config);
}
Modified: trunk/src/lm_site_youtube.js
===================================================================
--- trunk/src/lm_site_youtube.js 2011-04-05 10:22:41 UTC (rev 33)
+++ trunk/src/lm_site_youtube.js 2011-04-06 11:40:48 UTC (rev 34)
@@ -97,7 +97,7 @@
label += " 3GP";
break;
default:
- label += _("Unkown container");
+ label += this._("Unkown container");
}
// Set video and audio encodings
@@ -122,7 +122,7 @@
label += " MPEG-4 Visual, AAC";
break;
default:
- label += " " + _("Unkown encoding");
+ label += " " + this._("Unkown encoding");
}
link.label = link_data[1] + " " +label;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [linterna-magica-commit] [34] Final fix for bugs #32740.,
Ivaylo Valkov <=