Permalink
Browse files

Bug 1018708 - Collection localizations for homescreen + add localizat…

…ions to shared r=kgrandon
  • Loading branch information...
lightsofapollo authored and KevinGrandon committed Jun 19, 2014
1 parent 65c9a76 commit c5dd47e3f9e18872961946735fdbc071a1656ac9
@@ -11,6 +11,7 @@
<link rel="stylesheet" href="style/css/create.css">
<link rel="resource" type="application/l10n" href="locales/locales.ini">
<link rel="resource" type="application/l10n" href="/shared/locales/collection_categories.ini">
<script defer src="shared/js/l10n.js"></script>
<script defer src="shared/js/settings_listener.js"></script>
@@ -6,6 +6,7 @@
<link rel="stylesheet" href="style/css/base.css">
<link rel="resource" type="application/l10n" href="locales/locales.ini">
<script src="shared/js/l10n.js"></script>
<script src="shared/js/component_utils.js"></script>
@@ -4,8 +4,7 @@
(function(exports) {
const l10nKey = 'categoryId-';
const l10nKey = 'collection-categoryId-';
var _ = navigator.mozL10n.get;
var map = Array.prototype.map;

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -1,4 +1 @@
@import url(collection.en-US.properties)
[fr]
@import url(categories.fr.properties)
@@ -67,8 +67,8 @@ suite('suggestions > ', function() {
test('l10n logic', function(done) {
// set l10n items
navigator.mozL10n.set('categoryId-1', 'fromL10nFile');
navigator.mozL10n.set('categoryId-2', 'fromL10nFile');
navigator.mozL10n.set('collection-categoryId-1', 'fromL10nFile');
navigator.mozL10n.set('collection-categoryId-2', 'fromL10nFile');
var stubCategories = [
// will be found by l10n, and queries will be overwritten
@@ -10,6 +10,7 @@
<link rel="stylesheet" href="style/css/search.css">
<link rel="stylesheet" href="style/css/zoom.css">
<link rel="resource" type="application/l10n" href="locales/locales.ini">
<link rel="resource" type="application/l10n" href="/shared/locales/collection_categories.ini">
<script defer src="shared/js/l10n.js"></script>
@@ -70,6 +70,37 @@ marionette('Vertical - Collection', function() {
});
});
test('collection name localization', function() {
var collectionName = 'Entertainment';
collection.enterCreateScreen();
collection.selectNew([collectionName]);
client.apps.switchToApp(Home2.URL);
var collectionIcon =
collection.getCollectionByName(collectionName);
// switch to a different locale
client.executeScript(function() {
navigator.mozSettings.createLock().set({
// this is a dynamicly generated locale from english which is perfect
// for testing this kind of thing since as long as there is an english
// locale this will work.
'language.current': 'qps-ploc'
});
});
var expected = home.l10n(
'/locales-obj/qps-ploc.json',
// XXX: harcoded number 376 taken from the fixture
'collection-categoryId-376'
);
client.waitFor(function() {
return expected === collectionIcon.text();
});
});
test('pin collection web result', function() {
collection.enterCreateScreen();
@@ -36,6 +36,17 @@
"canonicalName": "autos",
"query": "Autos",
"categoryId": 3
},
{
"appIds": [
1,
2,
3
],
"locale": "en_US",
"canonicalName": "entertainment",
"query": "Entertainment",
"categoryId": 376
}
],
"icons": {
@@ -2,7 +2,7 @@
/* global MockApp, App, MocksHelper, loadBodyHTML, CollectionSource */
require('/shared/js/collections_database.js');
require('/shared/js/l10n.js');
require('/shared/test/unit/load_body_html_helper.js');
require('/shared/elements/gaia_grid/js/grid_dragdrop.js');
require('/shared/elements/gaia_grid/js/grid_icon_renderer.js');
@@ -5,6 +5,9 @@
/*jshint nonew: false */
(function(exports) {
const l10nKey = 'collection-categoryId-';
var _ = navigator.mozL10n.get;
/**
* Represents a single collection on the homepage.
@@ -23,6 +26,9 @@
pinned: collection.pinned,
defaultIconBlob: collection.defaultIconBlob
};
// XXX: One listener per collection may not be ideal.
window.addEventListener('localized', this.onLocalize.bind(this));
}
Collection.prototype = {
@@ -31,6 +37,18 @@
renderer: GridIconRenderer.TYPE.CLIP,
/**
Bug 1026236 l10n does not automatically handle these for us so
we handle locale updates ourselves.
*/
onLocalize: function() {
if (!this.element) {
return;
}
var nameEl = this.element.querySelector('.title');
nameEl.textContent = this.name;
},
/**
* Returns the height in pixels of each icon.
*/
@@ -40,11 +58,13 @@
/**
* Width in grid units for each icon.
* nameEl.textContent = this.name;
*/
gridWidth: 1,
get name() {
return this.detail.name;
// first attempt to use the localized name
return _(l10nKey + this.detail.categoryId) || this.detail.name;
},
/**
@@ -0,0 +1,4 @@
@import url(collection_categories/collection_categories.en-US.properties)
[fr]
@import url(collection_categories/collection_categories.fr.properties)
@@ -0,0 +1,72 @@
collection-categoryId-22=Books
collection-categoryId-142=Music
collection-categoryId-181=Movies
collection-categoryId-194=Internet
collection-categoryId-207=Games
collection-categoryId-211=Video
collection-categoryId-213=TV
collection-categoryId-220=Restaurants
collection-categoryId-225=Celebs
collection-categoryId-238=Shopping
collection-categoryId-242=Images
collection-categoryId-244=Tech
collection-categoryId-245=News
collection-categoryId-248=Email
collection-categoryId-249=Weather
collection-categoryId-256=Culture
collection-categoryId-260=Sports
collection-categoryId-270=Recipes
collection-categoryId-271=Reference
collection-categoryId-272=Travel Guides
collection-categoryId-274=Jobs
collection-categoryId-275=Medical
collection-categoryId-277=Funny
collection-categoryId-279=Learning & Education
collection-categoryId-282=Fashion
collection-categoryId-286=Electronics
collection-categoryId-288=Autos
collection-categoryId-289=Social
collection-categoryId-291=Video Games
collection-categoryId-292=Daily Deals
collection-categoryId-294=Personal Communication
collection-categoryId-296=Around Me
collection-categoryId-297=Astrology
collection-categoryId-302=Kids
collection-categoryId-303=Financial Services
collection-categoryId-306=Travel
collection-categoryId-316=Hotels
collection-categoryId-320=Dating
collection-categoryId-321=Financial News
collection-categoryId-325=Baseball
collection-categoryId-338=Classifieds
collection-categoryId-347=Baby
collection-categoryId-349=Photography
collection-categoryId-356=Beauty
collection-categoryId-357=Utilities
collection-categoryId-360=Productivity
collection-categoryId-365=Comics
collection-categoryId-366=Lifestyle
collection-categoryId-368=Personalization
collection-categoryId-372=Transportation
collection-categoryId-373=Telecommunication
collection-categoryId-376=Entertainment
collection-categoryId-377=Soccer
collection-categoryId-381=Religion
collection-categoryId-382=Fitness
collection-categoryId-387=Outdoor Activities
collection-categoryId-399=DIY
collection-categoryId-449=I'm So Bored
collection-categoryId-462=Telenovelas
collection-categoryId-463=Politics
collection-categoryId-473=Cricket
collection-categoryId-491=World Cup
collection-categoryId-501=Brazilian Apps
collection-categoryId-504=Bollywood
collection-categoryId-505=Food & Drinks
collection-categoryId-507=Travel & Local
collection-categoryId-510=Tech & Science
collection-categoryId-511=Media & Video
collection-categoryId-512=Health & Fitness
collection-categoryId-513=Business
collection-categoryId-520=Cycling
collection-categoryId-521=Surf
@@ -0,0 +1,3 @@
collection-categoryId-245=custom.fr
collection-categoryId-207=custom.fr
collection-categoryId-296=custom.fr

0 comments on commit c5dd47e

Please sign in to comment.