Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove i18n tech debt from 0.14 #7550

Merged
merged 5 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions kolibri/core/assets/src/mixins/commonCoreStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ export const coreStrings = createTranslator('CommonCoreStrings', {
context:
"\nCould also be translated as \"View information about providing identifier\"\n\nAll 'AriaLabel' type of messages are providing additional context to the screen-reader users. \n\nIn this case the screen-reader will announce the message to the user indicating that they can access more information and examples about the 'Identifier' through the 'i' icon.",
},

// Content activity
notStartedLabel: {
message: 'Not started',
context: 'For content that has not been viewed or engaged with yet',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is context and not the user string, but still remembering that we should steer away from the term content 🙂

Maybe Used to indicate a resource that learners did not yet open and engage with?

Copy link
Contributor Author

@jonboiser jonboiser Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "resource" the most generic term? I would probably even pick something more generic than "content" because "Not started" is a status for things like Exams and Lessons. This string was extracted as a status indicator for an Exam and I think I just wanted to give it a generic category as a common string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the coach tools we actually have distinct labels for each type to ensure that the gender agreement is correct. For example:

Lesson not started:

labelShort: '{count, plural, other {Not started}}',

Exercise not started:

labelShort: '{count, plural, other {Not started}}',

Also for:

  • Question
  • Quiz
  • Resource

},
});

export default {
Expand Down
6 changes: 2 additions & 4 deletions kolibri/plugins/coach/assets/src/csv/fields.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pad from 'lodash/padStart';
import get from 'lodash/get';
import { crossComponentTranslator, createTranslator, formatList } from 'kolibri.utils.i18n';
import PageStatus from 'kolibri.coreVue.components.PageStatus';
import { createTranslator, formatList } from 'kolibri.utils.i18n';
import coreStringsMixin from 'kolibri.coreVue.mixins.commonCoreStrings';
import { STATUSES } from '../modules/classSummary/constants';
import { VERBS } from '../views/common/status/constants';
Expand Down Expand Up @@ -35,7 +34,6 @@ const VERB_MAP = {
[STATUSES.completed]: VERBS.completed,
};
const coreStrings = coreStringsMixin.methods.coreString;
const examStrings = crossComponentTranslator(PageStatus);

/*
* Common CSV export fields and formats
Expand Down Expand Up @@ -189,7 +187,7 @@ export function score() {
export function tally() {
return [
{
name: examStrings.$tr('notStartedLabel'),
name: coreStrings('notStartedLabel'),
key: 'tally.notStarted',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createTranslator } from 'kolibri.utils.i18n';
const coachStrings = createTranslator('CommonCoachStrings', {
// actions
copyAction: 'Copy',
createLessonAction: 'Create new lesson',
exportCSVAction: 'Export as CSV',
manageResourcesAction: 'Manage resources',
newLessonAction: 'New lesson',
Expand Down Expand Up @@ -79,6 +80,10 @@ const coachStrings = createTranslator('CommonCoachStrings', {
createdNotification: 'Created',
deletedNotification: 'Deleted',

// errors
saveLessonError: 'There was a problem saving this lesson',
duplicateLessonTitleError: 'A lesson with that name already exists',

// empty states
activityListEmptyState: 'There is no activity',
groupListEmptyState: 'There are no groups',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
immersivePageIcon="close"
:immersivePagePrimary="false"
:immersivePageRoute="{ name: 'PLAN_LESSONS_ROOT' }"
:appBarTitle="lessonCreationStrings.$tr('newLessonModalTitle')"
:appBarTitle="coachString('createLessonAction')"
:authorized="true"
authorizedRole="adminOrCoach"
:pageTitle="lessonCreationStrings.$tr('newLessonModalTitle')"
:pageTitle="coachString('createLessonAction')"
:marginBottom="72"
>
<KPageContainer>
<AssignmentDetailsModal
ref="detailsModal"
assignmentType="new_lesson"
:modalTitleErrorMessage="lessonCreationStrings.$tr('duplicateTitle')"
:submitErrorMessage="lessonCreationStrings.$tr('saveLessonError')"
:modalTitleErrorMessage="coachString('duplicateLessonTitleErrorTitle')"
:submitErrorMessage="coachString('saveLessonError')"
:initialDescription="''"
:initialTitle="''"
:initialSelectedCollectionIds="[classId]"
Expand All @@ -35,10 +35,8 @@

<script>

import { crossComponentTranslator } from 'kolibri.utils.i18n';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import AssignmentDetailsModal from '../assignments/AssignmentDetailsModal';
import LessonRootPage from '../LessonsRootPage';
import commonCoach from '../../common';

export default {
Expand All @@ -49,9 +47,6 @@
classId() {
return this.$route.params.classId;
},
lessonCreationStrings() {
return crossComponentTranslator(LessonRootPage);
},
},
mounted() {
this.$store.commit('CORE_SET_PAGE_LOADING', false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

<KModal
v-if="showModal"
:title="$tr('newLessonModalTitle')"
:title="coachString('createLessonAction')"
:submitText="coreString('continueAction')"
:cancelText="coreString('cancelAction')"
:submitDisabled="detailsModalIsDisabled"
Expand All @@ -98,8 +98,8 @@
<AssignmentDetailsModal
ref="detailsModal"
assignmentType="new_lesson"
:modalTitleErrorMessage="$tr('duplicateTitle')"
:submitErrorMessage="$tr('saveLessonError')"
:modalTitleErrorMessage="coachString('duplicateLessonTitleError')"
:submitErrorMessage="coachString('saveLessonError')"
:initialDescription="''"
:initialTitle="''"
:initialSelectedCollectionIds="[classId]"
Expand Down Expand Up @@ -224,13 +224,10 @@
allLessons: 'All lessons',
activeLessons: 'Active lessons',
inactiveLessons: 'Inactive lessons',
newLessonModalTitle: 'Create new lesson',
size: 'Size',
noLessons: 'You do not have any lessons',
noActiveLessons: 'No active lessons',
noInactiveLessons: 'No inactive lessons',
saveLessonError: 'There was a problem saving this lesson',
duplicateTitle: 'A lesson with that name already exists',
visibleToLearnersLabel: {
message: 'Visible to learners',
context:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</HeaderWithOptions>

<p v-if="facilityTasks.length === 0">
{{ emptyTasksMessage }}
{{ deviceString('emptyTasksMessage') }}
</p>
<div>
<FacilityTaskPanel
Expand All @@ -42,16 +42,13 @@
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import commonTaskStrings from 'kolibri.coreVue.mixins.commonTaskStrings';
import commonSyncElements from 'kolibri.coreVue.mixins.commonSyncElements';
import { crossComponentTranslator } from 'kolibri.utils.i18n';
import HeaderWithOptions from '../HeaderWithOptions';
import { taskIsClearable } from '../../constants';
import ManageTasksPage from '../ManageTasksPage';
import BackLink from '../ManageTasksPage/BackLink';
import commonDeviceStrings from '../commonDeviceStrings';
import FacilityTaskPanel from './FacilityTaskPanel';
import facilityTasksQueue from './facilityTasksQueue';

const ManageTasksPageStrings = crossComponentTranslator(ManageTasksPage);

export default {
name: 'FacilitiesTasksPage',
metaInfo() {
Expand All @@ -64,8 +61,13 @@
HeaderWithOptions,
BackLink,
},
mixins: [commonCoreStrings, commonTaskStrings, commonSyncElements, facilityTasksQueue],
props: {},
mixins: [
commonCoreStrings,
commonTaskStrings,
commonSyncElements,
facilityTasksQueue,
commonDeviceStrings,
],
data() {
return {
// (facilityTasksQueue) facilityTasks
Expand All @@ -75,10 +77,6 @@
someClearableTasks() {
return Boolean(this.facilityTasks.find(taskIsClearable));
},
emptyTasksMessage() {
// eslint-disable-next-line kolibri/vue-no-undefined-string-uses
return ManageTasksPageStrings.$tr('emptyTasksMessage');
},
},
methods: {
handleClickClearAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<template v-if="isUnlistedChannel" v-slot:belowname>
<KTooltip reference="lockicon" :refs="$refs" placement="top">
{{ $tr('unlistedChannelTooltip') }}
{{ deviceString('unlistedChannelLabel') }}
</KTooltip>
<div class="private-icons">
<KIcon
Expand All @@ -35,7 +35,7 @@
color: $themeTokens.textInverted,
backgroundColor: $themeTokens.success
}"
>{{ $tr('newLabel') }}</span>
>{{ deviceString('newChannelLabel') }}</span>
</div>
</template>

Expand Down Expand Up @@ -91,14 +91,15 @@
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import { selectContentPageLink } from '../manageContentLinks';
import { PageNames } from '../../../constants';
import commonDeviceStrings from '../../commonDeviceStrings';
import ChannelDetails from './ChannelDetails';

export default {
name: 'WithImportDetails',
components: {
ChannelDetails,
},
mixins: [commonCoreStrings, responsiveWindowMixin],
mixins: [commonCoreStrings, responsiveWindowMixin, commonDeviceStrings],
props: {
channel: {
type: Object,
Expand Down Expand Up @@ -170,12 +171,6 @@
$trs: {
onYourDevice: 'Resources on device',
selectResourcesAction: 'Select resources',
newLabel: {
message: 'New',
context:
'\nRefers to CHANNEL; indicates that it was recently updated, imported, and unlocked',
},
unlistedChannelTooltip: 'Unlisted channel',
newVersionMessage: 'New version available',
moreInformationLabel: 'More information',
channelSelectedNoFileSize: 'Selected',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<template v-slot:belowname>
<div class="private-icons">
<KTooltip reference="lockicon" :refs="$refs" placement="top">
{{ WithImportDetailsStrings.$tr('unlistedChannelTooltip') }}
{{ deviceString('unlistedChannelLabel') }}
</KTooltip>
<KIcon
v-if="channel.public === false"
Expand All @@ -25,7 +25,7 @@
color: $themeTokens.textInverted,
backgroundColor: $themeTokens.success
}"
>{{ WithImportDetailsStrings.$tr('newLabel') }}</span>
>{{ deviceString('newChannelLabel') }}</span>
</div>
</template>
</ChannelDetails>
Expand Down Expand Up @@ -57,18 +57,15 @@
import responsiveWindowMixin from 'kolibri.coreVue.mixins.responsiveWindowMixin';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import bytesForHumans from 'kolibri.utils.bytesForHumans';
import { crossComponentTranslator } from 'kolibri.utils.i18n';
import commonDeviceStrings from '../../commonDeviceStrings';
import ChannelDetails from './ChannelDetails';
import WithImportDetails from './WithImportDetails';

const WithImportDetailsStrings = crossComponentTranslator(WithImportDetails);

export default {
name: 'WithSizeAndOptions',
components: {
ChannelDetails,
},
mixins: [responsiveWindowMixin, commonCoreStrings],
mixins: [responsiveWindowMixin, commonCoreStrings, commonDeviceStrings],
props: {
channel: {
type: Object,
Expand All @@ -87,9 +84,6 @@
resourcesSizeText() {
return bytesForHumans(this.channel.on_device_file_size);
},
WithImportDetailsStrings() {
return WithImportDetailsStrings;
},
},
methods: {
handleManageChannelAction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class="new-label"
:style="{ color: $themeTokens.textInverted, backgroundColor: $themeTokens.success }"
>
{{ newString }}
{{ deviceString('newResourceLabel') }}
</span>

<span class="version-available">
Expand All @@ -26,25 +26,17 @@

<script>

import { crossComponentTranslator } from 'kolibri.utils.i18n';
import ChannelUpdateAnnotations from '../SelectContentPage/ChannelUpdateAnnotations';

const UpdateStrings = crossComponentTranslator(ChannelUpdateAnnotations);
import commonDeviceStrings from '../commonDeviceStrings';

export default {
name: 'NewChannelVersionBanner',
mixins: [commonDeviceStrings],
props: {
version: {
type: Number,
required: true,
},
},
computed: {
newString() {
// eslint-disable-next-line kolibri/vue-no-undefined-string-uses
return UpdateStrings.$tr('newResource');
},
},
$trs: {
versionAvailable: {
message: 'Version {version} is available',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<KLinearLoader v-if="loading" :delay="false" type="indeterminate" />

<p v-if="!loading && managedTasks.length === 0" class="empty-tasks-message">
{{ $tr('emptyTasksMessage') }}
{{ deviceString('emptyTasksMessage') }}
</p>
<transition-group name="fade" class="task-panels">
<TaskPanel
Expand All @@ -57,6 +57,7 @@
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import responsiveWindowMixin from 'kolibri.coreVue.mixins.responsiveWindowMixin';
import { PageNames, taskIsClearable } from '../../constants';
import commonDeviceStrings from '../commonDeviceStrings';

import TaskPanel from './TaskPanel';
import BackLink from './BackLink';
Expand All @@ -73,7 +74,7 @@
TaskPanel,
BackLink,
},
mixins: [responsiveWindowMixin, commonCoreStrings],
mixins: [responsiveWindowMixin, commonCoreStrings, commonDeviceStrings],
data() {
return {
loading: true,
Expand Down Expand Up @@ -123,7 +124,6 @@
backToChannelsAction: 'Back to channels',
tasksHeader: 'Tasks',
appBarTitle: 'Task manager',
emptyTasksMessage: 'There are no tasks to display',
clearCompletedAction: {
message: 'Clear completed',
context:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

<script>

import commonDeviceStrings from '../commonDeviceStrings';

export default {
name: 'ChannelUpdateAnnotations',
mixins: [commonDeviceStrings],
props: {
newResources: {
type: Number,
Expand Down Expand Up @@ -48,7 +51,7 @@
},
label() {
if (this.new && this.isTopic === false) {
return this.$tr('newResource');
return this.deviceString('newResourceLabel');
} else if (this.new && this.isTopic === true) {
return this.$tr('newResourcesInTopic', { count: this.newResources });
} else if (this.importing) {
Expand All @@ -58,10 +61,6 @@
},
},
$trs: {
newResource: {
message: 'New',
context: 'Label that is shown with resources that were added after upgrading the channel',
},
newResourcesInTopic: {
message: '{count} {count, plural, one {new} other {new}}',
context:
Expand Down