Skip to content

Commit 9c00672

Browse files
committed
Complete the integration CC Vocabulary into the application
1 parent e11dc9a commit 9c00672

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

src/App.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
<template>
22
<div id="app">
3-
<Header appName="cc-chooser"/>
3+
<Header :title="$t('chooser')"/>
44
<div class="container" id="site-container">
55
<Chooser v-model="selected"/>
66
<hr>
77
<HelpSection/>
88
<hr>
99
<HTMLGenerator :shortLicenseName="selected.shortName"/>
1010
</div>
11-
<Footer/>
11+
<Footer>
12+
<Locale/>
13+
</Footer>
1214
</div>
1315
</template>
1416
<script>
17+
// TODO Reduce custom styling in favour of Vocabulary styles
18+
import '@creativecommons/vocabulary/root.css'
19+
import '@creativecommons/vocabulary/vocabulary.css'
20+
1521
import Chooser from './components/Chooser'
1622
import HelpSection from './components/HelpSection'
1723
import HTMLGenerator from './components/HTMLGenerator'
18-
import { Header, Footer, LicenseIconography } from '@creativecommons/vocabulary'
24+
import { Header, Footer, LicenseIconography, Locale } from '@creativecommons/vocabulary'
1925
2026
export default {
2127
name: 'App',
@@ -25,13 +31,14 @@ export default {
2531
HTMLGenerator,
2632
Header,
2733
Footer,
28-
LicenseIconography
34+
LicenseIconography,
35+
Locale
2936
},
3037
data() {
3138
return {
3239
selected: {
33-
shortName: "CC BY 4.0",
34-
fullName: "Attribution 4.0 International"
40+
shortName: 'CC BY 4.0',
41+
fullName: 'Attribution 4.0 International'
3542
}
3643
}
3744
},
@@ -77,3 +84,6 @@ hr {
7784
}
7885
}
7986
</style>
87+
88+
<i18n src="./locales/App.json">
89+
</i18n>

src/i18n.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Vue from 'vue'
2+
import VueI18n from 'vue-i18n'
3+
4+
Vue.use(VueI18n)
5+
6+
function loadLocaleMessages() {
7+
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i)
8+
const messages = {}
9+
locales.keys().forEach(key => {
10+
const matched = key.match(/([A-Za-z0-9-_]+)\./i)
11+
if (matched && matched.length > 1) {
12+
const locale = matched[1]
13+
messages[locale] = locales(key)
14+
}
15+
})
16+
return messages
17+
}
18+
19+
export default new VueI18n({
20+
locale: process.env.VUE_APP_I18N_LOCALE || 'en',
21+
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en',
22+
messages: loadLocaleMessages()
23+
})

src/locales/App.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"en": {
3+
"chooser": "Chooser"
4+
},
5+
"hi": {
6+
"chooser": "चयनकर्ता"
7+
}
8+
}

src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Buefy from 'buefy'
66
import VueHead from 'vue-head'
77
import 'buefy/dist/buefy.css'
88
import 'bulma/css/bulma.min.css'
9+
import i18n from './i18n'
910

1011
import '@creativecommons/vocabulary/root.css'
1112
import '@creativecommons/vocabulary/vocabulary.css'
@@ -16,6 +17,7 @@ Vue.use(VueHead)
1617

1718
/* eslint-disable no-new */
1819
new Vue({
20+
i18n,
1921
el: '#app',
2022
components: { App },
2123
template: '<App/>'

0 commit comments

Comments
 (0)