1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

Feature #1004: Improvements in translation script and translation template generation.

This commit is contained in:
Hector Sanjuan 2011-12-12 15:19:45 +01:00
parent 48f363cebc
commit 3a00d1d42c
3 changed files with 103 additions and 39 deletions

View File

@ -1,19 +1,37 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
var lang=""
var lang_tmp="";
var locale = {};
var datatable_lang = "";
function tr(str){
var tmp = locale[str];
if ( tmp == null || tmp == "" ) {
//console.debug("trans: "+str);
//console.debug("Missing translation: "+str);
tmp = str;
}
return tmp;
};
//Pops up loading new language dialog. Retrieves the user template, updates the LANG variable.
//Updates template and session configuration and reloads the view.
function setLang(lang_str){
$('<div title="Changing language">Loading new language... please wait '+spinner+'</div>').dialog({
var lang_tmp="";
var dialog = $('<div title="Changing language">Loading new language... please wait '+spinner+'</div>').dialog({
draggable:false,
modal:true,
resizable:false,
@ -23,38 +41,41 @@ function setLang(lang_str){
});
var updateUserTemplate = function(request,user_json){
var template = user_json.USER.TEMPLATE;
var template_str="";
template["LANG"] = lang_tmp;
//convert json to ONE template format - simple conversion
$.each(template,function(key,value){
template_str += (key + '=' + '"' + value + '"\n');
});
var obj = {
data: {
id: uid,
extra_param: template_str
},
error: onError
};
OpenNebula.User.update(obj);
$.post('config',JSON.stringify({lang:lang_tmp}),function(){window.location.href = "."});
};
lang_tmp = lang_str;
var obj = {
data : {
id: uid,
},
success: updateUserTemplate
if (whichUI() == "sunstone"){
var obj = {
data : {
id: uid,
},
success: updateUserTemplate
};
OpenNebula.User.show(obj);
} else {
dialog.dialog('close');
};
OpenNebula.User.show(obj);
};
function updateUserTemplate(request,user_json){
var template = user_json.USER.TEMPLATE;
template["LANG"] = lang_tmp;
var template_str="";
$.each(template,function(key,value){
template_str += (key + '=' + '"' + value + '"\n');
});
var obj = {
data: {
id: uid,
extra_param: template_str
},
error: onError
};
OpenNebula.User.update(obj);
$.post('config',JSON.stringify({lang:lang_tmp}),refreshLang);
}
function refreshLang(){
window.location.href = ".";
};
$(document).ready(function(){
@ -64,6 +85,7 @@ $(document).ready(function(){
setLang($(this).val());
});
//Update static translations
$('#doc_link').text(tr("Documentation"));
$('#support_link').text(tr("Support"));
$('#community_link').text(tr("Community"));

View File

@ -102,6 +102,7 @@ locale={
"Datablock":"",
"Default":"",
"Default (current image type)":"",
"Define a subnet by IP range":"",
"Delete":"",
"Delete host":"",
"Deploy":"",
@ -156,7 +157,9 @@ locale={
"Hardware that will emulate this network interface. With Xen this is the type attribute of the vif.":"",
"hd":"",
"Historical monitoring information":"",
"hold":"",
"Hold":"",
"Hold lease":"",
"Host":"",
"Host information":"",
"Hostname":"",
@ -191,6 +194,8 @@ locale={
"Inputs":"",
"Instantiate":"",
"IP":"",
"IP End":"",
"IP Start":"",
"IP to listen on":"",
"Kernel":"",
"Kernel commands":"",
@ -199,7 +204,6 @@ locale={
"KVM":"",
"LCM State":"",
"Lease IP":"",
"Lease MAC":"",
"Lease MAC (opt):":"",
"Lease management":"",
"Leases information":"",
@ -236,8 +240,9 @@ locale={
"Network":"",
"Network Address":"",
"Network is unreachable: is OpenNebula running?":"",
"Network mask":"",
"Network Mask":"",
"Network reception":"",
"Network size":"",
"Network transmission":"",
"Network type":"",
"New":"",
@ -247,6 +252,7 @@ locale={
"No":"",
"No disk id or image name specified":"",
"No disks defined":"",
"No leases to show":"",
"None":"",
"Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU.":"",
"OK":"",
@ -284,7 +290,6 @@ locale={
"Please provide a resource ID for the resource(s) in this rule":"",
"Please select":"",
"Please select at least one resource":"",
"Please specify":"",
"Please specify to who this ACL applies":"",
"Port":"",
"Port blacklist":"",
@ -308,8 +313,8 @@ locale={
"Refresh list":"",
"Register time":"",
"Registration time":"",
"release":"",
"Release":"",
"Remove lease":"",
"Remove selected":"",
"Request an specific IP from the Network":"",
"Requirements":"",
@ -420,6 +425,7 @@ locale={
"Update template":"",
"USB":"",
"Use":"",
"Used by VM":"",
"Used CPU":"",
"Used CPU (allocated)":"",
"Used CPU (real)":"",
@ -446,8 +452,7 @@ locale={
"Virtual Network name missing!":"",
"Virtual Networks":"",
"Virtual Networks (total/public)":"",
"Virtual network template":"",
"Virtual Network template":"",
"Virtual Network template (attributes)":"",
"VM information":"",
"VM Instance":"",
"VM Instances":"",
@ -466,6 +471,8 @@ locale={
"VNC connection":"",
"VNC Disabled":"",
"VNC Session":"",
"VNET ID":"",
"VN MAD":"",
"Welcome":"",
"Wizard":"",
"Wizard KVM":"",

View File

@ -1,8 +1,43 @@
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
#tr_strings = $stdin.read
tr_strings = `grep -h -o -R -e 'tr("[[:print:]]*")' ../js/* | cut -d'"' -f 2 | sort -u`
puts '/* -------------------------------------------------------------------------- */
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
'
puts "//Default translation template"
puts 'lang="en_US"'
puts 'datatable_lang=""'