chaals avatar chaals committed 046f9e1

v 1.1 - factoring out localisation better, added swedish (thanks Peter)

Comments (0)

Files changed (12)

 <?xml version="1.0" encoding="utf-8"?>
-<widget xmlns="http://www.w3.org/ns/widgets" version="1.0">
+<widget xmlns="http://www.w3.org/ns/widgets" version="1.1">
 	<name>Swaplang</name>
         <author href="http://my.opera.com/chaals">Chaals</author>
         <icon src="ic.png" width="64" height="64"/>

locales/de/popup (Autosaved)

-<!DOCTYPE html>
-<meta 
-<head>
-<title>Swaplang Popup</title>
-<style>
-  :link {text-decoration:none}
-  a:hover {background: #ddd;}
-  * {margin: 0px ; padding: 0px}
-  p { line-height: 1.4em}
-  li { font-family: sans-serif; margin-left: 1.5em; }
-</style>
-</head>
-<body>
-<p id="para">Es gibt auch:</p>
-<ul id="list"></ul>
-</body>
-<script>
-  var portToUserJS;
-  //------------------------------------
-  //Direct messages are always from the userJS.
-  opera.extension.onmessage = function( event ){
-    //The port to communicate on
-      portToUserJS = event.ports[0];
-
-    
-    //Split the JSON data, and create the links
-      var languageChoices = JSON.parse( event.data );
-      var theList = document.getElementById('list');
-      for (i in languageChoices) {
-      //JSON data has a length and item attribute, which has to be ignored.
-        if(i == "length" || i == "item") continue;
-      
-      //Add a title, if none exists.
-        if (!(languageChoices[i].title)) {
-          languageChoices[i].title = "Wechseln zu: " + languageChoices[i].hreflang ;
-        }
-      
-      //Create links
-        var theItem = document.createElement("li");
-        var theLink = document.createElement('a');
-        theLink.textContent = languageChoices[i].title;
-        theLink.href = languageChoices[i].href;
-        theLink.onclick = function(event) {
-          opera.postError(this.href);
-          portToUserJS.postMessage(this.href);
-          event.preventDefault();
-          window.close();
-        }
-        theItem.appendChild(theLink);
-        theList.appendChild(theItem);
-      }
-  }
-  //------------------------------------
-</script>

locales/de/popup.html

-<!DOCTYPE html>
-<head>
-<meta name="Content-Type" content="text/html; charset = UTF-8">
-<title>Swaplang Popup</title>
-<style>
-  :link {text-decoration:none}
-  a:hover {background: #ddd;}
-  * {margin: 0px ; padding: 0px}
-  p { line-height: 1.4em}
-  li { font-family: sans-serif; margin-left: 1.5em; }
-</style>
-</head>
-<body>
-<p id="para">Es gibt auch:</p>
-<ul id="list"></ul>
-</body>
-<script>
-  var portToUserJS;
-  //------------------------------------
-  //Direct messages are always from the userJS.
-  opera.extension.onmessage = function( event ){
-    //The port to communicate on
-      portToUserJS = event.ports[0];
-
-    
-    //Split the JSON data, and create the links
-      var languageChoices = JSON.parse( event.data );
-      var theList = document.getElementById('list');
-      for (i in languageChoices) {
-      //JSON data has a length and item attribute, which has to be ignored.
-        if(i == "length" || i == "item") continue;
-      
-      //Add a title, if none exists.
-        if (!(languageChoices[i].title)) {
-          languageChoices[i].title = "Wechseln zu: " + languageChoices[i].hreflang ;
-        }
-      
-      //Create links
-        var theItem = document.createElement("li");
-        var theLink = document.createElement('a');
-        theLink.textContent = languageChoices[i].title;
-        theLink.href = languageChoices[i].href;
-        theLink.onclick = function(event) {
-          opera.postError(this.href);
-          portToUserJS.postMessage(this.href);
-          event.preventDefault();
-          window.close();
-        }
-        theItem.appendChild(theLink);
-        theList.appendChild(theItem);
-      }
-  }
-  //------------------------------------
-</script>

locales/de/strings.js

+var stringSet = {
+alsoAvailable	:"Es gibt auch:",
+changeTo	:"Wechseln zu "
+}
Add a comment to this file

locales/es/.DS_Store

Binary file removed.

locales/es/popup.html

-<!DOCTYPE html>
-<head>
-<meta name="Content-Type" content="text/html; charset = UTF-8">
-<title>Swaplang Popup - español</title>
-<style>
-  :link {text-decoration:none}
-  a:hover {background: #ddd;}
-  * {margin: 0px ; padding: 0px}
-  p { line-height: 1.4em}
-  li { font-family: sans-serif; margin-left: 1.5em; }
-</style>
-</head>
-<body>
-<p id="para">También hay:</p>
-<ul id="list"></ul>
-</body>
-<script>
-  var portToUserJS;
-  //------------------------------------
-  //Direct messages are always from the userJS.
-  opera.extension.onmessage = function( event ){
-    //The port to communicate on
-      portToUserJS = event.ports[0];
-
-    
-    //Split the JSON data, and create the links
-      var languageChoices = JSON.parse( event.data );
-      var theList = document.getElementById('list');
-      for (i in languageChoices) {
-      //JSON data has a length and item attribute, which has to be ignored.
-        if(i == "length" || i == "item") continue;
-      
-      //Add a title, if none exists.
-        if (!(languageChoices[i].title)) {
-          languageChoices[i].title = "Idioma: " + languageChoices[i].hreflang ;
-        }
-      
-      //Create links
-        var theItem = document.createElement("li");
-        var theLink = document.createElement('a');
-        theLink.textContent = languageChoices[i].title;
-        theLink.href = languageChoices[i].href;
-        theLink.onclick = function(event) {
-          opera.postError(this.href);
-          portToUserJS.postMessage(this.href);
-          event.preventDefault();
-          window.close();
-        }
-        theItem.appendChild(theLink);
-        theList.appendChild(theItem);
-      }
-  }
-  //------------------------------------
-</script>

locales/es/strings.js

+var stringSet = {
+alsoAvailable	:"Tambien hay:",
+changeTo	:"Idioma "
+}

locales/fr/popup.html

-<!DOCTYPE html>
-<head>
-<meta name="Content-Type" content="text/html; charset = UTF-8">
-<title>Swaplang Popup</title>
-<style>
-  :link {text-decoration:none}
-  a:hover {background: #ddd;}
-  * {margin: 0px ; padding: 0px}
-  p { line-height: 1.4em}
-  li { font-family: sans-serif; margin-left: 1.5em; }
-</style>
-</head>
-<body>
-<p id="para">Il y a aussi:</p>
-<ul id="list"></ul>
-</body>
-<script>
-  var portToUserJS;
-  //------------------------------------
-  //Direct messages are always from the userJS.
-  opera.extension.onmessage = function( event ){
-    //The port to communicate on
-      portToUserJS = event.ports[0];
-
-    
-    //Split the JSON data, and create the links
-      var languageChoices = JSON.parse( event.data );
-      var theList = document.getElementById('list');
-      for (i in languageChoices) {
-      //JSON data has a length and item attribute, which has to be ignored.
-        if(i == "length" || i == "item") continue;
-      
-      //Add a title, if none exists.
-        if (!(languageChoices[i].title)) {
-          languageChoices[i].title = "Changer �: " + languageChoices[i].hreflang ;
-        }
-      
-      //Create links
-        var theItem = document.createElement("li");
-        var theLink = document.createElement('a');
-        theLink.textContent = languageChoices[i].title;
-        theLink.href = languageChoices[i].href;
-        theLink.onclick = function(event) {
-          opera.postError(this.href);
-          portToUserJS.postMessage(this.href);
-          event.preventDefault();
-          window.close();
-        }
-        theItem.appendChild(theLink);
-        theList.appendChild(theItem);
-      }
-  }
-  //------------------------------------
-</script>

locales/fr/strings.js

+var stringSet = {
+alsoAvailable	:"Aussi disponible:",
+changeTo	:"Changer à "
+}

locales/sv/strings.js

+var stringSet = {
+alsoAvailable	:"Finns också:",
+changeTo	:"Byt till  "
+}
   p { line-height: 1.4em}
   li { font-family: sans-serif; margin-left: 1.5em; }
 </style>
+<script src="strings.js"></script>
 </head>
 <body>
 <p id="para">Also available:</p>
 <ul id="list"></ul>
 </body>
 <script>
+  //localise
+  var theP = document.getElementById('para');
+  para.innerText = stringSet.alsoAvailable;
+
   var portToUserJS;
   //------------------------------------
   //Direct messages are always from the userJS.
       
       //Add a title, if none exists.
         if (!(languageChoices[i].title)) {
-          languageChoices[i].title = "Change to " + languageChoices[i].hreflang ;
+          languageChoices[i].title = stringSet.changeTo + languageChoices[i].hreflang ;
         }
       
       //Create links
+var stringSet = {
+alsoAvailable	:"Also available",
+changeTo	:"Change to "
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.