Skip to content

Commit

Permalink
Remove all usage of localize filter, use either directive or local co…
Browse files Browse the repository at this point in the history
…mputeds
  • Loading branch information
dannon committed Oct 23, 2023
1 parent af0a28c commit 94e0925
Show file tree
Hide file tree
Showing 29 changed files with 193 additions and 69 deletions.
12 changes: 10 additions & 2 deletions client/src/components/ActivityBar/ActivityItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useRouter } from "vue-router/composables";
import TextShort from "@/components/Common/TextShort.vue";
import Popper from "@/components/Popper/Popper.vue";
import { localize } from "@/utils/localization";
const router = useRouter();
interface Option {
Expand Down Expand Up @@ -43,6 +44,13 @@ const emit = defineEmits<{
(e: "click"): void;
}>();
const localized = computed(() => {
return {
tooltip: localize(props.tooltip),
title: localize(props.title),
};
});
function onClick(evt: MouseEvent): void {
emit("click");
if (props.to) {
Expand All @@ -58,7 +66,7 @@ function onClick(evt: MouseEvent): void {
<b-nav-item
class="position-relative my-1 p-2"
:class="{ 'nav-item-active': isActive }"
:aria-label="title | l">
:aria-label="localized.title">
<span v-if="progressStatus" class="progress">
<div
class="progress-bar notransition"
Expand All @@ -83,7 +91,7 @@ function onClick(evt: MouseEvent): void {
</div>
</template>
<div class="text-center px-2 py-1">
<small v-if="tooltip">{{ tooltip | l }}</small>
<small v-if="tooltip">{{ localized.tooltip }}</small>
<small v-else>No tooltip available for this item</small>
<div v-if="options" class="nav-options p-1">
<router-link v-for="(option, index) in options" :key="index" :to="option.value">
Expand Down
11 changes: 9 additions & 2 deletions client/src/components/Annotation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
class="annotation"
tag-name="p"
:value="annotation"
:title="'Edit annotation...' | localize"
:placeholder="'Edit annotation...' | localize">
:title="localized.title"
:placeholder="localized.title">
<DebouncedInput v-slot="inputScope" v-model="annotation" :delay="1000">
<b-form-textarea
size="sm"
Expand All @@ -24,6 +24,8 @@
</template>

<script>
import localize from "@/utils/localization";
import ClickToEdit from "./ClickToEdit";
import DebouncedInput from "./DebouncedInput";
Expand All @@ -47,6 +49,11 @@ export default {
}
},
},
localized() {
return {
title: localize("Edit annotation..."),
};
},
},
};
</script>
Expand Down
13 changes: 11 additions & 2 deletions client/src/components/Common/DelayedInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
size="sm"
:pressed="showAdvanced"
:variant="showAdvanced ? 'info' : 'secondary'"
:title="titleAdvanced | l"
:title="localized.titleAdvanced"
data-description="toggle advanced search"
@click="onToggle">
<icon v-if="showAdvanced" fixed-width icon="angle-double-up" />
Expand All @@ -30,7 +30,7 @@
aria-haspopup="true"
class="search-clear"
size="sm"
:title="titleClear | l"
:title="localized.titleClear"
data-description="reset query"
@click="clearBox">
<icon v-if="loading" fixed-width icon="spinner" spin />
Expand All @@ -40,6 +40,7 @@
</b-input-group>
</template>
<script>
import localize from "@/utils/localization";
export default {
props: {
query: {
Expand Down Expand Up @@ -86,6 +87,14 @@ export default {
this.setQuery(this.query);
}
},
computed: {
localized() {
return {
titleClear: localize(this.titleClear),
titleAdvanced: localize(this.titleAdvanced),
};
},
}
methods: {
clearTimer() {
if (this.queryTimer) {
Expand Down
43 changes: 31 additions & 12 deletions client/src/components/DatasetInformation/DatasetAttributes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<div aria-labelledby="dataset-attributes-heading">
<h1 id="dataset-attributes-heading" v-localize class="h-lg">Edit Dataset Attributes</h1>
<b-alert v-if="messageText" class="dataset-attributes-alert" :variant="messageVariant" show>
{{ messageText | l }}
{{ localized.messageText }}
</b-alert>
<DatasetAttributesProvider :id="datasetId" v-slot="{ result, loading }" @error="onError">
<div v-if="!loading" class="mt-3">
<b-tabs>
<b-tab v-if="!result['attribute_disable']">
<template v-slot:title>
<FontAwesomeIcon icon="bars" class="mr-1" />{{ "Attributes" | l }}
<FontAwesomeIcon icon="bars" class="mr-1" />{{ localized.attributes }}
</template>
<FormDisplay :inputs="result['attribute_inputs']" @onChange="onAttribute" />
<div class="mt-2">
Expand All @@ -18,10 +18,10 @@
variant="primary"
class="mr-1"
@click="submit('attribute', 'attributes')">
<FontAwesomeIcon icon="save" class="mr-1" />{{ "Save" | l }}
<FontAwesomeIcon icon="save" class="mr-1" />{{ localized.save }}
</b-button>
<b-button v-if="!result['metadata_disable']" @click="submit('attribute', 'autodetect')">
<FontAwesomeIcon icon="redo" class="mr-1" />{{ "Auto-detect" | l }}
<FontAwesomeIcon icon="redo" class="mr-1" />{{ localized.autoDetect }}
</b-button>
</div>
</b-tab>
Expand All @@ -31,25 +31,25 @@
!result['metadata_disable']
">
<template v-slot:title>
<FontAwesomeIcon icon="database" class="mr-1" />{{ "Datatypes" | l }}
<FontAwesomeIcon icon="database" class="mr-1" />{{ localized.datatypes }}
</template>
<div v-if="!result['datatype_disable']" class="ui-portlet-section">
<div class="portlet-header">
<div class="portlet-title">
<FontAwesomeIcon icon="database" class="portlet-title-icon fa-fw mr-1" />
<span class="portlet-title-text">
<b itemprop="name">{{ "Assign Datatype" | l }}</b>
<b itemprop="name">{{ localized.assignDatatype }}</b>
</span>
</div>
</div>
<div class="portlet-content">
<FormDisplay :inputs="result['datatype_inputs']" @onChange="onDatatype" />
<div class="mt-2">
<b-button variant="primary" class="mr-1" @click="submit('datatype', 'datatype')">
<FontAwesomeIcon icon="save" class="mr-1" />{{ "Save" | l }}
<FontAwesomeIcon icon="save" class="mr-1" />{{ localized.save }}
</b-button>
<b-button @click="submit('datatype', 'datatype_detect')">
<FontAwesomeIcon icon="redo" class="mr-1" />{{ "Auto-detect" | l }}
<FontAwesomeIcon icon="redo" class="mr-1" />{{ localized.autoDetect }}
</b-button>
</div>
</div>
Expand All @@ -59,28 +59,30 @@
<div class="portlet-title">
<FontAwesomeIcon icon="cog" class="portlet-title-icon fa-fw mr-1" />
<span class="portlet-title-text">
<b itemprop="name">{{ "Convert to Datatype" | l }}</b>
<b itemprop="name">{{ localized.convertToDatatype }}</b>
</span>
</div>
</div>
<div class="portlet-content">
<FormDisplay :inputs="result['conversion_inputs']" @onChange="onConversion" />
<div class="mt-2">
<b-button variant="primary" @click="submit('conversion', 'conversion')">
<FontAwesomeIcon icon="exchange-alt" class="mr-1" />{{ "Create Dataset" | l }}
<FontAwesomeIcon icon="exchange-alt" class="mr-1" />{{
localized.createDatatype
}}
</b-button>
</div>
</div>
</div>
</b-tab>
<b-tab v-if="!result['permission_disable']">
<template v-slot:title>
<FontAwesomeIcon icon="user" class="mr-1" />{{ "Permissions" | l }}
<FontAwesomeIcon icon="user" class="mr-1" />{{ localized.permissions }}
</template>
<FormDisplay :inputs="result['permission_inputs']" @onChange="onPermission" />
<div class="mt-2">
<b-button variant="primary" @click="submit('permission', 'permission')">
<FontAwesomeIcon icon="save" class="mr-1" />{{ "Save" | l }}
<FontAwesomeIcon icon="save" class="mr-1" />{{ localized.save }}
</b-button>
</div>
</b-tab>
Expand All @@ -98,6 +100,8 @@ import { getGalaxyInstance } from "app";
import FormDisplay from "components/Form/FormDisplay";
import { DatasetAttributesProvider } from "components/providers/DatasetProvider";
import { localize } from "@/utils/localization";
import { setAttributes } from "./services";
library.add(faBars, faCog, faDatabase, faExchangeAlt, faRedo, faSave, faUser);
Expand All @@ -121,6 +125,21 @@ export default {
formData: {},
};
},
computed: {
localized() {
return {
messageText: localize(this.messageText),
attributes: localize("Attributes"),
save: localize("Save"),
autoDetect: localize("Auto-detect"),
datatypes: localize("Datatypes"),
assignDatatype: localize("Assign Datatype"),
convertToDatatype: localize("Convert to Datatype"),
createDataset: localize("Create Dataset"),
permissions: localize("Permissions"),
};
},
},
methods: {
onAttribute(data) {
this.formData["attribute"] = data;
Expand Down
8 changes: 7 additions & 1 deletion client/src/components/DatasetInformation/DatasetError.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<div v-if="showForm" id="fieldsAndButton">
<span class="mr-2 font-weight-bold">{{ emailTitle }}</span>
<span v-if="!!currentUser?.email">{{ currentUser?.email }}</span>
<span v-else>{{ "You must be logged in to receive emails" | l }}</span>
<span v-else>{{ localized.loginForEmail }}</span>
<FormElement
id="dataset-error-message"
v-model="message"
Expand Down Expand Up @@ -95,6 +95,7 @@ import { mapState } from "pinia";
import { useMarkdown } from "@/composables/markdown";
import { useUserStore } from "@/stores/userStore";
import { localize } from "@/utils/localization";
import DatasetErrorDetails from "./DatasetErrorDetails";
import { sendErrorReport } from "./services";
Expand Down Expand Up @@ -135,6 +136,11 @@ export default {
const hasError = this.resultMessages.some((msg) => msg[1] === "danger");
return noResult || hasError;
},
localized() {
return {
loginForEmail: localize("You must be logged in to receive emails"),
};
},
},
methods: {
onError(err) {
Expand Down
10 changes: 8 additions & 2 deletions client/src/components/Form/FormGeneric.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
</FormCard>
<div class="mt-3">
<b-button id="submit" variant="primary" class="mr-1" @click="onSubmit()">
<span :class="submitIconClass" />{{ submitTitle | l }}
<span :class="submitIconClass" />{{ localized.submitTitle }}
</b-button>
<b-button v-if="cancelRedirect" @click="onCancel()">
<span class="mr-1 fa fa-times" />{{ "Cancel" | l }}
<span class="mr-1 fa fa-times" />{{ localized.cancel }}
</b-button>
</div>
</div>
Expand Down Expand Up @@ -85,6 +85,12 @@ export default {
submitIconClass() {
return `mr-1 fa ${this.submitIcon}`;
},
localized() {
return {
submitTitle: this.submitTitle,
cancel: "Cancel",
};
},
},
methods: {
configTitle(options) {
Expand Down
9 changes: 8 additions & 1 deletion client/src/components/Form/FormMessage.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<template>
<b-alert class="mt-2" :variant="variant" :show="showAlert">
{{ message | l }}
{{ localized.message }}
</b-alert>
</template>
<script>
import { localize } from "@/utils/localization";
export default {
props: {
message: {
Expand Down Expand Up @@ -38,6 +40,11 @@ export default {
}
return false;
},
localized() {
return {
message: localize(this.message),
};
},
},
watch: {
message(newMessage) {
Expand Down
11 changes: 10 additions & 1 deletion client/src/components/History/CurrentHistory/HistoryEmpty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<b-alert show>
<h4 class="mb-1">
<i class="fa fa-info-circle empty-message"></i>
<span>{{ message | l }}</span>
<span>{{ localized.message }}</span>
</h4>
<p v-if="writable">
<a v-localize href="#" @click.prevent="openGlobalUploadModal">You can load your own data</a>
Expand All @@ -15,6 +15,8 @@
<script>
import { useGlobalUploadModal } from "composables/globalUploadModal";
import { localize } from "@/utils/localization";
export default {
props: {
message: { type: String, default: "This history is empty." },
Expand All @@ -24,6 +26,13 @@ export default {
const { openGlobalUploadModal } = useGlobalUploadModal();
return { openGlobalUploadModal };
},
computed: {
localized() {
return {
message: localize(this.message),
};
},
},
methods: {
clickDataLink() {
this.eventHub.$emit("openToolSection", "getext");
Expand Down
14 changes: 9 additions & 5 deletions client/src/components/History/CurrentHistory/HistoryMessages.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<template>
<div v-if="hasMessages" class="mx-3 my-2">
<b-alert :show="history.isDeleted" variant="warning">
{{ "This history has been deleted" | localize }}
{{ localized.isDeleted }}
</b-alert>
<b-alert :show="userOverQuota" variant="warning">
{{
"You are over your disk quota. Tool execution is on hold until your disk usage drops below your allocated quota."
| localize
}}
{{ localized.userOverQuota }}
</b-alert>
</div>
</template>
Expand All @@ -26,6 +23,13 @@ export default {
hasMessages() {
return this.userOverQuota || history.isDeleted;
},
localized() {
return {
isDeleted: "This history has been deleted",
userOverQuota:
"You are over your disk quota. Tool execution is on hold until your disk usage drops below your allocated quota.",
};
},
},
};
</script>
Loading

0 comments on commit 94e0925

Please sign in to comment.