Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature fix: Make 'Go Fullscreen' button localizable #627

Merged
merged 1 commit into from Nov 15, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
462 changes: 341 additions & 121 deletions build/mediaelement-and-player.js

Large diffs are not rendered by default.

37 changes: 20 additions & 17 deletions build/mediaelement-and-player.min.js

Large diffs are not rendered by default.

220 changes: 220 additions & 0 deletions build/mediaelement.js
Expand Up @@ -1571,3 +1571,223 @@ function onYouTubePlayerReady(id) {
window.mejs = mejs;
window.MediaElement = mejs.MediaElement;

/*!
* Adds Internationalization and localization to objects.
*
* What is the concept beyond i18n?
* http://en.wikipedia.org/wiki/Internationalization_and_localization
*
*
* This file both i18n methods and locale which is used to translate
* strings into other languages.
*
* Default translations are not available, you have to add them
* through locale objects which are named exactly as the langcode
* they stand for. The default language is always english (en).
*
*
* Wrapper built to be able to attach the i18n object to
* other objects without changing more than one line.
*
*
* LICENSE:
*
* The i18n file uses methods from the Drupal project (drupal.js):
* - i18n.methods.t() (modified)
* - i18n.methods.checkPlain() (full copy)
* - i18n.methods.formatString() (full copy)
*
* The Drupal project is (like mediaelementjs) licensed under GPLv2.
* - http://drupal.org/licensing/faq/#q1
* - https://github.com/johndyer/mediaelement
* - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*
* @author
* Tim Latz (latz.tim@gmail.com)
*
* @see
* me-i18n-locale.js
*
* @params
* - $ - zepto || jQuery ..
* - context - document, iframe ..
* - exports - CommonJS, window ..
*
*/
;(function($, context, exports, undefined) {
"use strict";
var i18n = {
"locale": {
"strings" : {}
},
"methods" : {}
};
// start i18n


/**
* Get the current browser's language
*
* @see: i18n.methods.t()
*/
i18n.locale.getLanguage = function () {
return {
"language" : navigator.language
};
};

/**
* Store the language the locale object was initialized with
*/
i18n.locale.INIT_LANGUAGE = i18n.locale.getLanguage();


/**
* Encode special characters in a plain-text string for display as HTML.
*/
i18n.methods.checkPlain = function (str) {
var character, regex,
replace = {
'&': '&',
'"': '"',
'<': '&lt;',
'>': '&gt;'
};
str = String(str);
for (character in replace) {
if (replace.hasOwnProperty(character)) {
regex = new RegExp(character, 'g');
str = str.replace(regex, replace[character]);
}
}
return str;
};

/**
* Replace placeholders with sanitized values in a string.
*
* @param str
* A string with placeholders.
* @param args
* An object of replacements pairs to make. Incidences of any key in this
* array are replaced with the corresponding value. Based on the first
* character of the key, the value is escaped and/or themed:
* - !variable: inserted as is
* - @variable: escape plain text to HTML (i18n.methods.checkPlain)
* - %variable: escape text and theme as a placeholder for user-submitted
* content (checkPlain + <em class="placeholder" > )
*
* @see i18n.methods.t()
*/
i18n.methods.formatString = function(str, args) {
// Transform arguments before inserting them.
for (var key in args) {
switch (key.charAt(0)) {
// Escaped only.
case '@':
args[key] = i18n.methods.checkPlain(args[key]);
break;
// Pass-through.
case '!':
break;
// Escaped and placeholder.
case '%':
default:
args[key] = '<em class="placeholder">' + i18n.methods.checkPlain(args[key]) + '</em>';
break;
}
str = str.replace(key, args[key]);
}
return str;
};

/**
* Translate strings to the page language or a given language.
*
* See the documentation of the server-side t() function for further details.
*
* @param str
* A string containing the English string to translate.
* @param args
* An object of replacements pairs to make after translation. Incidences
* of any key in this array are replaced with the corresponding value.
* See i18n.methods.formatString().
*
* @param options
* - 'context' (defaults to the default context): The context the source string
* belongs to.
*
* @return
* The translated string.
*/
i18n.methods.t = function (str, args, options) {

// Fetch the localized version of the string.
if (i18n.locale.strings && i18n.locale.strings[options.context] && i18n.locale.strings[options.context][str]) {
str = i18n.locale.strings[options.context][str];
}

if (args) {
str = i18n.methods.formatString(str, args);
}
return str;
};


/**
* Wrapper for i18n.methods.t()
*
* @see i18n.methods.t()
* @throws InvalidArgumentException
*/
i18n.t = function(str, args, options) {

if (typeof str === 'string' && str.length > 0) {

// check every time due languge can change for
// different reasons (translation, lang switcher ..)
var lang = i18n.locale.getLanguage();

options = options || {
"context" : lang.language
};

return i18n.methods.t(str, args, options);
}
else {
throw {
"name" : 'InvalidArgumentException',
"message" : 'First argument is either not a string or empty.'
}
}
};

// end i18n
exports.i18n = i18n;
}(jQuery, document, mejs));
/*!
* This is a i18n.locale language object.
*
*<de> German translation by Tim Latz, latz.tim@gmail.com
*
* @author
* Tim Latz (latz.tim@gmail.com)
*
* @see
* me-i18n.js
*
* @params
* - exports - CommonJS, window ..
*/
;(function(exports, undefined) {

"use strict";

exports.de = {
"Fullscreen" : "Vollbild",
"Go Fullscreen" : "Vollbild an",
"Turn off Fullscreen" : "Vollbild aus"
};

}(mejs.i18n.locale.strings));