Updated some JS translate methods to correctly take in context

This commit is contained in:
Phil Hughes 2017-05-03 12:02:26 +01:00
parent 6d5364cfb0
commit 93f27958d0
13 changed files with 72 additions and 59 deletions

View file

@ -9,7 +9,7 @@ export default {
<span v-if="count === 50" class="events-info pull-right">
<i class="fa fa-warning has-tooltip"
aria-hidden="true"
:title="__('Limited to showing 50 events at most')"
:title="n__('Limited to showing %d event at most', 'Limited to showing %d events at most', 50)"
data-placement="top"></i>
{{ n__('Showing %d event', 'Showing %d events', 50) }}
</span>

View file

@ -15,7 +15,7 @@ global.cycleAnalytics.TotalTimeComponent = Vue.extend({
<template v-if="time.days">{{ time.days }} <span>{{ n__('day', 'days', time.days) }}</span></template>
<template v-if="time.hours">{{ time.hours }} <span>{{ n__('Time|hr', 'Time|hrs', time.hours) }}</span></template>
<template v-if="time.mins && !time.days">{{ time.mins }} <span>{{ n__('Time|min', 'Time|mins', time.mins) }}</span></template>
<template v-if="time.seconds && Object.keys(time).length === 1 || time.seconds === 0">{{ time.seconds }} <span>{{ __('Time|s') }}</span></template>
<template v-if="time.seconds && Object.keys(time).length === 1 || time.seconds === 0">{{ time.seconds }} <span>{{ s__('Time|s') }}</span></template>
</template>
<template v-else>
--

View file

@ -1 +1 @@
var locales = locales || {}; locales['de'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-04-12 22:37-0500","Last-Translator":"FULL NAME <EMAIL@ADDRESS>","Language-Team":"German","Language":"de","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Plural-Forms":"nplurals=2; plural=n != 1;","lang":"de","domain":"app","plural_forms":"nplurals=2; plural=n != 1;"},"Author|by":[""],"Commits":[""],"Cycle":[""],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":[""],"Cycle|Code":[""],"Cycle|Issue":[""],"Cycle|Plan":[""],"Cycle|Review":[""],"Cycle|Staging":[""],"Cycle|Test":[""],"Deploys":[""],"Introducing Cycle Analytics":[""],"Last 30 days":[""],"Last 90 days":[""],"Limited to showing 50 events at most":[""],"Median":[""],"New Issues":[""],"Not available":[""],"Not enough data":[""],"OfFirstTime|First":[""],"Opened":[""],"Pipeline Health":[""],"ProjectLifecycle|Stage":[""],"Read more":[""],"Related Commits":[""],"Related Issues":[""],"Related Merge Requests":[""],"Relative Builds Trigger by Commits":[""],"Relative Deployed Builds":[""],"Relative Merged Requests":[""],"Showing %d event":["",""],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":[""],"The collection of events added to the data gathered for that stage.":[""],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":[""],"The phase of the development lifecycle.":[""],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":[""],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":[""],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":[""],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":[""],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":[""],"The time taken by each data entry gathered by that stage.":[""],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":[""],"Time|hr":["",""],"Time|min":["",""],"Time|s":[""],"Total Time":[""],"Want to see the data? Please ask administrator for access.":[""],"We don't have enough data to show this stage.":[""],"You need permission.":[""],"day":["",""],"pushed by":[""]}}};
var locales = locales || {}; locales['de'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-04-12 22:37-0500","Last-Translator":"FULL NAME <EMAIL@ADDRESS>","Language-Team":"German","Language":"de","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Plural-Forms":"nplurals=2; plural=n != 1;","lang":"de","domain":"app","plural_forms":"nplurals=2; plural=n != 1;"},"Author|by":[""],"Commits":[""],"Cycle":[""],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":[""],"Cycle|Code":[""],"Cycle|Issue":[""],"Cycle|Plan":[""],"Cycle|Review":[""],"Cycle|Staging":[""],"Cycle|Test":[""],"Deploys":[""],"Introducing Cycle Analytics":[""],"Last %d day":["",""],"Limited to showing %d event at most":["",""],"Median":[""],"New Issues":[""],"Not available":[""],"Not enough data":[""],"OfFirstTime|First":[""],"Opened":[""],"Pipeline Health":[""],"ProjectLifecycle|Stage":[""],"Read more":[""],"Related Commits":[""],"Related Issues":[""],"Related Merge Requests":[""],"Relative Builds Trigger by Commits":[""],"Relative Deployed Builds":[""],"Relative Merged Requests":[""],"Showing %d event":["",""],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":[""],"The collection of events added to the data gathered for that stage.":[""],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":[""],"The phase of the development lifecycle.":[""],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":[""],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":[""],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":[""],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":[""],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":[""],"The time taken by each data entry gathered by that stage.":[""],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":[""],"Time|hr":["",""],"Time|min":["",""],"Time|s":[""],"Total Time":[""],"Want to see the data? Please ask an administrator for access.":[""],"We don't have enough data to show this stage.":[""],"You need permission.":[""],"day":["",""],"pushed by":[""]}}};

View file

@ -1 +1 @@
var locales = locales || {}; locales['en'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-04-12 22:36-0500","Last-Translator":"FULL NAME <EMAIL@ADDRESS>","Language-Team":"English","Language":"en","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Plural-Forms":"nplurals=2; plural=n != 1;","lang":"en","domain":"app","plural_forms":"nplurals=2; plural=n != 1;"},"Author|by":[""],"Commits":[""],"Cycle":[""],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":[""],"Cycle|Code":[""],"Cycle|Issue":[""],"Cycle|Plan":[""],"Cycle|Review":[""],"Cycle|Staging":[""],"Cycle|Test":[""],"Deploys":[""],"Introducing Cycle Analytics":[""],"Last 30 days":[""],"Last 90 days":[""],"Limited to showing 50 events at most":[""],"Median":[""],"New Issues":[""],"Not available":[""],"Not enough data":[""],"OfFirstTime|First":[""],"Opened":[""],"Pipeline Health":[""],"ProjectLifecycle|Stage":[""],"Read more":[""],"Related Commits":[""],"Related Issues":[""],"Related Merge Requests":[""],"Relative Builds Trigger by Commits":[""],"Relative Deployed Builds":[""],"Relative Merged Requests":[""],"Showing %d event":["",""],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":[""],"The collection of events added to the data gathered for that stage.":[""],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":[""],"The phase of the development lifecycle.":[""],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":[""],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":[""],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":[""],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":[""],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":[""],"The time taken by each data entry gathered by that stage.":[""],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":[""],"Time|hr":["",""],"Time|min":["",""],"Time|s":[""],"Total Time":[""],"Want to see the data? Please ask administrator for access.":[""],"We don't have enough data to show this stage.":[""],"You need permission.":[""],"day":["",""],"pushed by":[""]}}};
var locales = locales || {}; locales['en'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-04-12 22:36-0500","Last-Translator":"FULL NAME <EMAIL@ADDRESS>","Language-Team":"English","Language":"en","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Plural-Forms":"nplurals=2; plural=n != 1;","lang":"en","domain":"app","plural_forms":"nplurals=2; plural=n != 1;"},"Author|by":[""],"Commits":[""],"Cycle":[""],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":[""],"Cycle|Code":[""],"Cycle|Issue":[""],"Cycle|Plan":[""],"Cycle|Review":[""],"Cycle|Staging":[""],"Cycle|Test":[""],"Deploys":[""],"Introducing Cycle Analytics":[""],"Last %d day":["",""],"Limited to showing %d event at most":["",""],"Median":[""],"New Issues":[""],"Not available":[""],"Not enough data":[""],"OfFirstTime|First":[""],"Opened":[""],"Pipeline Health":[""],"ProjectLifecycle|Stage":[""],"Read more":[""],"Related Commits":[""],"Related Issues":[""],"Related Merge Requests":[""],"Relative Builds Trigger by Commits":[""],"Relative Deployed Builds":[""],"Relative Merged Requests":[""],"Showing %d event":["",""],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":[""],"The collection of events added to the data gathered for that stage.":[""],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":[""],"The phase of the development lifecycle.":[""],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":[""],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":[""],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":[""],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":[""],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":[""],"The time taken by each data entry gathered by that stage.":[""],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":[""],"Time|hr":["",""],"Time|min":["",""],"Time|s":[""],"Total Time":[""],"Want to see the data? Please ask an administrator for access.":[""],"We don't have enough data to show this stage.":[""],"You need permission.":[""],"day":["",""],"pushed by":[""]}}};

File diff suppressed because one or more lines are too long

View file

@ -1,15 +1,18 @@
import Jed from 'jed';
import { de } from './de/app';
import { es } from './es/app';
import { en } from './en/app';
const locales = {
de,
es,
en,
};
function requireAll(requireContext) { return requireContext.keys().map(requireContext); }
const lang = document.querySelector('html').getAttribute('lang') || 'en';
const allLocales = requireAll(require.context('./', true, /^(?!.*(?:index.js$)).*\.js$/));
const locales = allLocales.reduce((d, obj) => {
const data = d;
const localeKey = Object.keys(obj)[0];
data[localeKey] = obj[localeKey];
return data;
}, {});
const lang = document.querySelector('html').getAttribute('lang').replace(/-/g, '_') || 'en';
const locale = new Jed(locales[lang]);
const gettext = locale.gettext.bind(locale);
const ngettext = locale.ngettext.bind(locale);

View file

@ -1,7 +1,6 @@
import {
__,
n__,
s__,
} from '../locale';
export default (Vue) => {
@ -9,9 +8,16 @@ export default (Vue) => {
methods: {
__(text) { return __(text); },
n__(text, pluralText, count) {
return n__(text, pluralText, count).replace(/%d/g, count);
const translated = n__(text, pluralText, count).replace(/%d/g, count).split('|');
return translated[translated.length - 1];
},
s__(keyOrContext, key) {
const normalizedKey = key ? `${keyOrContext}|${key}` : keyOrContext;
// eslint-disable-next-line no-underscore-dangle
const translated = this.__(normalizedKey).split('|');
return translated[translated.length - 1];
},
s__(context, key) { return s__(context, key); },
},
});
};

View file

@ -4,4 +4,4 @@
= custom_icon ('icon_lock')
%h4 {{ __('You need permission.') }}
%p
{{ __('Want to see the data? Please ask administrator for access.') }}
{{ __('Want to see the data? Please ask an administrator for access.') }}

View file

@ -20,8 +20,7 @@
%p
{{ __('Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.') }}
= link_to help_page_path('user/project/cycle_analytics'), target: '_blank', class: 'btn' do
{{ __('Read more') }}
= link_to _('Read more'), help_page_path('user/project/cycle_analytics'), target: '_blank', class: 'btn'
= icon("spinner spin", "v-show" => "isLoading")
.wrapper{ "v-show" => "!isLoading && !hasError" }
.panel.panel-default
@ -32,19 +31,19 @@
.row
.col-sm-3.col-xs-12.column{ "v-for" => "item in state.summary" }
%h3.header {{ item.value }}
%p.text {{ __(item.title) }}
%p.text {{ s__('Cycle', item.title) }}
.col-sm-3.col-xs-12.column
.dropdown.inline.js-ca-dropdown
%button.dropdown-menu-toggle{ "data-toggle" => "dropdown", :type => "button" }
%span.dropdown-label {{ __('Last 30 days') }}
%span.dropdown-label {{ n__('Last %d day', 'Last %d days', 30) }}
%i.fa.fa-chevron-down
%ul.dropdown-menu.dropdown-menu-align-right
%li
%a{ "href" => "#", "data-value" => "30" }
{{ __('Last 30 days') }}
{{ n__('Last %d day', 'Last %d days', 30) }}
%li
%a{ "href" => "#", "data-value" => "90" }
{{ __('Last 90 days') }}
{{ n__('Last %d day', 'Last %d days', 90) }}
.stage-panel-container
.panel.panel-default.stage-panel
.panel-heading
@ -52,7 +51,7 @@
%ul
%li.stage-header
%span.stage-name
{{ __('ProjectLifecycle|Stage') }}
{{ s__('ProjectLifecycle|Stage') }}
%i.has-tooltip.fa.fa-question-circle{ "data-placement" => "top", title: _("The phase of the development lifecycle."), "aria-hidden" => "true" }
%li.median-header
%span.stage-name

View file

@ -53,14 +53,15 @@ msgstr ""
msgid "Introducing Cycle Analytics"
msgstr ""
msgid "Last 30 days"
msgstr ""
msgid "Last %d day"
msgid_plural "Last %d days"
msgstr[0] ""
msgstr[1] ""
msgid "Last 90 days"
msgstr ""
msgid "Limited to showing 50 events at most"
msgstr ""
msgid "Limited to showing %d event at most"
msgid_plural "Limited to showing %d events at most"
msgstr[0] ""
msgstr[1] ""
msgid "Median"
msgstr ""
@ -161,7 +162,7 @@ msgstr ""
msgid "Total Time"
msgstr ""
msgid "Want to see the data? Please ask administrator for access."
msgid "Want to see the data? Please ask an administrator for access."
msgstr ""
msgid "We don't have enough data to show this stage."

View file

@ -53,14 +53,15 @@ msgstr ""
msgid "Introducing Cycle Analytics"
msgstr ""
msgid "Last 30 days"
msgstr ""
msgid "Last %d day"
msgid_plural "Last %d days"
msgstr[0] ""
msgstr[1] ""
msgid "Last 90 days"
msgstr ""
msgid "Limited to showing 50 events at most"
msgstr ""
msgid "Limited to showing %d event at most"
msgid_plural "Limited to showing %d events at most"
msgstr[0] ""
msgstr[1] ""
msgid "Median"
msgstr ""
@ -161,7 +162,7 @@ msgstr ""
msgid "Total Time"
msgstr ""
msgid "Want to see the data? Please ask administrator for access."
msgid "Want to see the data? Please ask an administrator for access."
msgstr ""
msgid "We don't have enough data to show this stage."

View file

@ -59,14 +59,15 @@ msgstr "Despliegues"
msgid "Introducing Cycle Analytics"
msgstr "Introducción a Cycle Analytics"
msgid "Last 30 days"
msgstr "Últimos 30 días"
#, fuzzy
msgid "Last %d day"
msgid_plural "Last %d days"
msgstr[0] "Últimos %d días"
msgid "Last 90 days"
msgstr "Últimos 90 días"
msgid "Limited to showing 50 events at most"
msgstr "Limitado a mostrar máximo 50 eventos"
#, fuzzy
msgid "Limited to showing %d event at most"
msgid_plural "Limited to showing %d events at most"
msgstr[0] "Limitado a mostrar máximo %d eventos"
msgid "Median"
msgstr "Mediana"
@ -170,7 +171,8 @@ msgstr ""
msgid "Total Time"
msgstr "Tiempo Total"
msgid "Want to see the data? Please ask administrator for access."
#, fuzzy
msgid "Want to see the data? Please ask an administrator for access."
msgstr "¿Quieres ver los datos? Por favor pedir acceso al administrador."
msgid "We don't have enough data to show this stage."

View file

@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-02 23:33-0500\n"
"PO-Revision-Date: 2017-05-02 23:33-0500\n"
"POT-Creation-Date: 2017-05-03 12:00+0100\n"
"PO-Revision-Date: 2017-05-03 12:00+0100\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
@ -54,14 +54,15 @@ msgstr ""
msgid "Introducing Cycle Analytics"
msgstr ""
msgid "Last 30 days"
msgstr ""
msgid "Last %d day"
msgid_plural "Last %d days"
msgstr[0] ""
msgstr[1] ""
msgid "Last 90 days"
msgstr ""
msgid "Limited to showing 50 events at most"
msgstr ""
msgid "Limited to showing %d event at most"
msgid_plural "Limited to showing %d events at most"
msgstr[0] ""
msgstr[1] ""
msgid "Median"
msgstr ""
@ -162,7 +163,7 @@ msgstr ""
msgid "Total Time"
msgstr ""
msgid "Want to see the data? Please ask administrator for access."
msgid "Want to see the data? Please ask an administrator for access."
msgstr ""
msgid "We don't have enough data to show this stage."