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

vue-cli UI localization #987

Merged
merged 2 commits into from
Mar 15, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@vue/cli-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"subscriptions-transport-ws": "^0.9.5",
"vue": "^2.5.13",
"vue-apollo": "^3.0.0-beta.5",
"vue-i18n": "^7.6.0",
"vue-instantsearch": "^1.5.1",
"vue-router": "^3.0.1",
"xterm": "^3.2.0"
Expand Down
14 changes: 7 additions & 7 deletions packages/@vue/cli-ui/src/components/FolderExplorer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<VueButton
class="icon-button"
icon-left="keyboard_arrow_up"
v-tooltip="'Open parent folder'"
v-tooltip="$t('components.folder-explorer.toolbar.tooltips.parent-folder')"
@click="openParentFolder"
/>

<div v-if="editingPath" class="path-edit">
<VueInput
ref="pathInput"
v-model="editedPath"
placeholder="Enter the full path to a folder"
:placeholder="$t('components.folder-explorer.toolbar.placeholder')"
icon-left="edit"
@keyup.esc="editingPath = false"
@keyup.enter="submitPathEdit()"
Expand All @@ -28,7 +28,7 @@
v-else
:query="require('@/graphql/cwd.gql')"
class="current-path"
v-tooltip="'Edit path'"
v-tooltip="$t('components.folder-explorer.toolbar.tooltips.edit-path')"
@click.native="openPathEdit()"
>
<ApolloSubscribeToMore
Expand All @@ -50,7 +50,7 @@
<VueButton
class="icon-button favorite-button"
:icon-left="folderCurrent.favorite ? 'star' : 'star_border'"
v-tooltip="'Toggle favorite'"
v-tooltip="$t('components.folder-explorer.toolbar.tooltips.favorite')"
@click="toggleFavorite()"
/>

Expand All @@ -61,7 +61,7 @@
slot="trigger"
icon-left="arrow_drop_down"
class="icon-button"
v-tooltip="'Favorite folders'"
v-tooltip="$t('components.folder-explorer.toolbar.tooltips.favorite-folders')"
/>

<template v-if="foldersFavorite.length">
Expand All @@ -75,14 +75,14 @@
</template>

<div v-else class="vue-ui-empty">
No favorite folders yet.
{{ $t('components.folder-explorer.toolbar.empty') }}
</div>
</VueDropdown>

<VueButton
class="icon-button"
icon-left="refresh"
v-tooltip="'Refresh'"
v-tooltip="$t('components.folder-explorer.toolbar.tooltips.refresh')"
@click="refreshFolder"
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-ui/src/components/InstantSearchInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
icon-left="search"
v-model="query"
class="big"
placeholder="Search a plugin"
:placeholder="$t('components.instant-search-input.placeholder')"
>
<template slot="right">
<VueButton
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-ui/src/components/ListItemInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@click.stop="() => {}"
>
<VueIcon icon="open_in_new" class="medium top"/>
More info
{{ $t('components.list-item-info.more-info') }}
</a>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions packages/@vue/cli-ui/src/components/LoggerView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
icon="dvr"
/>
<div class="title">
Logs
{{ $t('components.logger-view.title') }}
</div>
<VueButton
class="icon-button"
icon-left="delete_forever"
v-tooltip="'Clear logs'"
v-tooltip="$t('components.logger-view.buttons.clear')"
@click="clearLogs()"
/>
<VueIcon
Expand All @@ -20,13 +20,13 @@
<VueButton
class="icon-button"
icon-left="subdirectory_arrow_left"
v-tooltip="'Scroll to bottom'"
v-tooltip="$t('components.logger-view.buttons.scroll')"
@click="scrollToBottom()"
/>
<VueButton
class="icon-button"
icon-left="close"
v-tooltip="'Close'"
v-tooltip="$t('components.logger-view.buttons.close')"
@click="close()"
/>
</div>
Expand Down Expand Up @@ -56,7 +56,7 @@
class="vue-ui-empty"
>
<VueIcon icon="wifi" class="large"/>
<div>No logs yet</div>
<div>{{ $t('components.logger-view.empty') }}</div>
</div>
</template>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-ui/src/components/ProgressScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="actions">
<VueButton
icon-left="close"
label="Close"
:label="$t('components.progress-screen.close')"
@click="close()"
/>
</div>
Expand Down
14 changes: 10 additions & 4 deletions packages/@vue/cli-ui/src/components/ProjectNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class="flat big icon-button"
:value="route.name"
:icon-left="route.icon"
v-tooltip.right="route.tooltip"
v-tooltip.right="renderTooltip(route.tooltip)"
/>
</VueGroup>
</div>
Expand All @@ -24,17 +24,17 @@ const BUILTIN_ROUTES = [
{
name: 'project-plugins',
icon: 'widgets',
tooltip: 'Plugins'
tooltip: 'plugins'
},
{
name: 'project-configuration',
icon: 'settings_applications',
tooltip: 'Configuration'
tooltip: 'configuration'
},
{
name: 'project-tasks',
icon: 'assignment',
tooltip: 'Tasks'
tooltip: 'tasks'
}
]

Expand Down Expand Up @@ -65,6 +65,12 @@ export default {
}
}
},

methods: {
renderTooltip (target) {
return this.$t(`components.project-nav.tooltips.${target}`)
}
}
}
</script>

Expand Down
8 changes: 4 additions & 4 deletions packages/@vue/cli-ui/src/components/ProjectPluginItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
>
<span slot="description" class="plugin-description">
<span class="info version">
<span class="label">version</span>
<span class="label">{{ $t('components.project-plugin-item.version') }}</span>
<span class="value">{{ plugin.version.current }}</span>
</span>

<span class="info latest">
<span class="label">latest</span>
<span class="label">{{ $t('components.project-plugin-item.latest') }}</span>
<VueIcon
v-if="plugin.version.current !== plugin.version.latest"
icon="warning"
Expand All @@ -28,15 +28,15 @@
icon="star"
class="top medium"
/>
Official
{{ $t('components.project-plugin-item.official') }}
</span>

<span v-if="plugin.installed" class="info">
<VueIcon
icon="check_circle"
class="top medium"
/>
Installed
{{ $t('components.project-plugin-item.installed') }}
</span>

<span v-if="plugin.description" class="package-description">
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-ui/src/components/ProjectSelectList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
<div v-else class="vue-ui-empty">
<VueIcon icon="attach_file" class="empty-icon"/>
<div>No existing projects</div>
<div>{{ $t('components.project-select-list.empty') }}</div>
</div>
</template>
</template>
Expand Down
4 changes: 2 additions & 2 deletions packages/@vue/cli-ui/src/components/ProjectSelectListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<VueButton
class="icon-button"
:icon-left="project.favorite ? 'star' : 'star_border'"
v-tooltip="'Toggle favorite'"
v-tooltip="$t('components.project-select-list-item.tooltips.favorite')"
@click.stop="$emit('favorite')"
/>
</div>
Expand All @@ -19,7 +19,7 @@
<VueButton
class="icon-button"
icon-left="delete"
v-tooltip="'Delete'"
v-tooltip="$t('components.project-select-list-item.tooltips.delete')"
@click.stop="$emit('remove')"
/>
</div>
Expand Down
10 changes: 5 additions & 5 deletions packages/@vue/cli-ui/src/components/StatusBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
<div class="content">
<div
class="section action current-project"
v-tooltip="'Current project<br><i>Click to toggle Project Manager</i>'"
v-tooltip="$t('components.status-bar.project.tooltip')"
@click="onProjectClick()"
>
<VueIcon icon="work"/>
<span v-if="projectCurrent">{{ projectCurrent.name }}</span>
<span v-else class="label">No project</span>
<span v-else class="label">{{ $t('components.status-bar.project.empty') }}</span>
</div>

<ApolloQuery
:query="require('@/graphql/cwd.gql')"
class="section current-path"
v-tooltip="'Current Working Directory'"
v-tooltip="$t('components.status-bar.path.tooltip')"
@click.native="onCwdClick()"
>
<ApolloSubscribeToMore
Expand All @@ -37,15 +37,15 @@

<div
class="section action console-log"
v-tooltip="'Logs<br><i>Click to toggle vue-cli logs</i>'"
v-tooltip="$t('components.status-bar.log.tooltip')"
@click="onConsoleClick()"
>
<VueIcon icon="dvr"/>
<LoggerMessage class="last-message"
v-if="consoleLogLast"
:message="consoleLogLast"
/>
<div v-else class="last-message">No logs yet</div>
<div v-else class="last-message">{{ $t('components.status-bar.log.empty') }}</div>
<!-- <TerminalView
:cols="100"
:rows="1"
Expand Down
33 changes: 33 additions & 0 deletions packages/@vue/cli-ui/src/i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Vue from 'vue'
import VueI18n from 'vue-i18n'

Vue.use(VueI18n)

function loadLocaleMessages () {
const locales = require.context('./locales', true, /[a-z0-9]+\.json$/i)
const messages = {}
locales.keys().forEach(key => {
const locale = key.match(/([a-z0-9]+)\./i)[1]
messages[locale] = locales(key)
})
return messages
}

function detectLanguage () {
try {
const lang = (window.navigator.languages && window.navigator.languages[0]) ||
window.navigator.language ||
window.navigator.userLanguage
return lang.substr(0, 2)
} catch (e) {
return undefined
}
}

const i18n = new VueI18n({
locale: detectLanguage() || 'en',
fallbackLocale: 'en',
messages: loadLocaleMessages()
})

export default i18n
Loading