diff --git a/apps/devhub/templates/devhub/base.html b/apps/devhub/templates/devhub/base.html index 08da4a637a..97cfe0f0ee 100644 --- a/apps/devhub/templates/devhub/base.html +++ b/apps/devhub/templates/devhub/base.html @@ -5,6 +5,10 @@ {% endif %} {% block bodyclass %}developer-hub {{ editable }}{% endblock %} +{% block bodyattrs %} +{% if addon %}data-default-locale="{{ addon.default_locale|lower }}"{% endif %} +{% endblock %} + {% block title %}{{ dev_page_title() }}{% endblock %} {% block extrahead %} diff --git a/media/css/zamboni/zamboni.css b/media/css/zamboni/zamboni.css index 06b93d7abd..86ca3b39e4 100644 --- a/media/css/zamboni/zamboni.css +++ b/media/css/zamboni/zamboni.css @@ -3193,6 +3193,16 @@ input.ui-autocomplete-loading { background-color: #2A4364; } +.trans [lang] { + display: none; +} +.trans [lang]:first-child { + display: block; +} +.trans .init-trans { + display: none; +} + .trans .cloned { color: #ccc; font-style: italic; diff --git a/media/js/zamboni/l10n.js b/media/js/zamboni/l10n.js index 35142283ef..464456ee43 100644 --- a/media/js/zamboni/l10n.js +++ b/media/js/zamboni/l10n.js @@ -1,13 +1,17 @@ // Yes, this is out here for a reason. // We want to hide the non-default locales as fast as possible. -if ($('.default-locale').length) { - $(format(".trans :not([lang={0}])", [$('.default-locale').attr('href').substring(1)])).hide(); -} +(function() { + var dl = $('body').attr("data-default-locale"); + if (dl) { + $(format(".trans :not([lang={0}])", dl)).hide(); + $(format(".trans [lang={0}]", dl)).show(); + } +})(); $(document).ready(function () { if (!$("#l10n-menu").length) return; var locales = [], - dl = $('.default-locale').attr('href').substring(1), + dl = $('body').attr("data-default-locale"), currentLocale = dl, unsavedModalMsg = $('#modal-l10n-unsaved .msg').html(), unsavedModal = $('#modal-l10n-unsaved').modal(), @@ -175,11 +179,16 @@ $(document).ready(function () { field = $el.attr('data-name'), label = $(format("label[data-for={0}]",[field])); if (!$el.find(format("[lang={0}]",[lang])).length) { - var $ni = $el.children(format("[lang={0}]",[dl])).clone(); - $ni.addClass("cloned").attr("lang", lang); + var $ni = $el.children(".init-trans").clone(); + $ni.attr({ + class: "cloned", + lang: lang, + }); if ($ni.is(':not(span)')) { - $ni.attr('id',format('id_{0}_{1}',[field,lang])) - .attr('name',[field,lang].join('_')); + $ni.attr({ + id: format('id_{0}_{1}', field, lang), + name: [field,lang].join('_') + }); } $el.append($ni); } @@ -192,8 +201,8 @@ $(document).ready(function () { } }); - $(format(".trans [lang!={0}]", [currentLocale])).hide(); - $(format(".trans [lang={0}]", [lang])).show(); + $(format(".trans :not([lang={0}])", currentLocale)).hide(); + $(format(".trans [lang={0}]", currentLocale)).show(); initCharCount(); } diff --git a/templates/base.html b/templates/base.html index eaa655f4b3..878e92d679 100644 --- a/templates/base.html +++ b/templates/base.html @@ -29,7 +29,8 @@ data-appid="{{ request.APP.id }}" data-anonymous="{{ (not request.user.is_authenticated())|json }}" data-readonly="{{ settings.READ_ONLY|json }}" - data-media-url="{{ MEDIA_URL }}"> + data-media-url="{{ MEDIA_URL }}" + {% block bodyattrs %}{% endblock %}> {% if request.ADMIN_MESSAGE or settings.READ_ONLY%}