diff --git a/.gitignore b/.gitignore index 8b5117034..ee2ed95e2 100644 --- a/.gitignore +++ b/.gitignore @@ -35,7 +35,6 @@ htmlcov # Translations *.mo -*.pot # Pycharm .idea @@ -75,6 +74,7 @@ api/static api/.pytest_cache # Front +front/static/translations front/node_modules/ front/dist/ front/npm-debug.log* diff --git a/changes/changelog.d/5.feature b/changes/changelog.d/5.feature new file mode 100644 index 000000000..d3600048e --- /dev/null +++ b/changes/changelog.d/5.feature @@ -0,0 +1 @@ +Add internationalization support (#5) diff --git a/dev.yml b/dev.yml index c0470a2ab..409b6b4a7 100644 --- a/dev.yml +++ b/dev.yml @@ -13,6 +13,7 @@ services: - "${WEBPACK_DEVSERVER_PORT-8080}:${WEBPACK_DEVSERVER_PORT-8080}" volumes: - './front:/app' + - './po:/po' postgres: env_file: diff --git a/front/build/dev-server.js b/front/build/dev-server.js index 634a6d41e..f9c389e72 100644 --- a/front/build/dev-server.js +++ b/front/build/dev-server.js @@ -14,6 +14,8 @@ var webpackConfig = process.env.NODE_ENV === 'testing' ? require('./webpack.prod.conf') : require('./webpack.dev.conf') +require('./i18n') + // default port where dev server listens for incoming traffic var port = process.env.PORT || config.dev.port var host = process.env.HOST || config.dev.host diff --git a/front/build/i18n.js b/front/build/i18n.js new file mode 100644 index 000000000..8739d06d2 --- /dev/null +++ b/front/build/i18n.js @@ -0,0 +1,39 @@ +const fs = require('fs'); +const path = require('path'); +const { gettextToI18next } = require('i18next-conv'); + +const poDir = path.join(__dirname, '..', '..', 'po') +const outDir = path.join(__dirname, '..', 'static', 'translations') +if (!fs.existsSync(outDir) || !fs.statSync(outDir).isDirectory()) { + fs.mkdirSync(outDir) +} + +// Convert .po files to i18next files +fs.readdir(poDir, (err, files) => { + if (err) { + return console.log(err) + } + + for (const file of files) { + if (file.endsWith('.po')) { + const lang = file.replace(/\.po$/, '') + const output = path.join(outDir, `${lang}.json`) + fs.readFile(path.join(poDir, file), (err, content) => { + if (err) { + return console.log(err) + } + + gettextToI18next(lang, content).then(res => { + fs.writeFile(output, res, err => { + if (err) { + console.log(err) + } else { + console.log(`Wrote translation file: ${output}`) + } + }) + }) + }) + } + } +}) + diff --git a/front/package.json b/front/package.json index d67375f7e..e480008c6 100644 --- a/front/package.json +++ b/front/package.json @@ -15,9 +15,13 @@ "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs" }, "dependencies": { + "@panter/vue-i18next": "^0.9.1", "axios": "^0.17.1", "dateformat": "^2.0.0", "django-channels": "^1.1.6", + "i18next": "^11.1.1", + "i18next-conv": "^6.0.0", + "i18next-fetch-backend": "^0.1.0", "js-logger": "^1.3.0", "jwt-decode": "^2.2.0", "lodash": "^4.17.4", @@ -34,7 +38,7 @@ "vue-upload-component": "^2.7.4", "vuedraggable": "^2.14.1", "vuex": "^3.0.1", - "vuex-persistedstate": "^2.4.2", + "vuex-persistedstate": "^2.5.2", "vuex-router-sync": "^5.0.0" }, "devDependencies": { diff --git a/front/src/App.vue b/front/src/App.vue index e8ab18694..e8cac7476 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -7,21 +7,25 @@
-

Links

+
-

About funkwhale

-

Funkwhale is a free and open-source project run by volunteers. You can help us improve the platform by reporting bugs, suggesting features and share the project with your friends!

-

The funkwhale logo was kindly designed and provided by Francis Gading.

+ +

+ +

+

+ +

@@ -31,7 +35,6 @@ :dsn="$store.state.instance.settings.raven.front_dsn.value"> - diff --git a/front/src/components/activity/Like.vue b/front/src/components/activity/Like.vue index ffb831278..deda121cc 100644 --- a/front/src/components/activity/Like.vue +++ b/front/src/components/activity/Like.vue @@ -5,17 +5,20 @@
- - favorited a track - + + + +
{{ event.object.name }} - - - + + {{ event.object.album }} + {{ event.object.artist }} + + + {{ event.object.artist }} +
diff --git a/front/src/components/activity/Listen.vue b/front/src/components/activity/Listen.vue index 7c8ee8a69..d207c280d 100644 --- a/front/src/components/activity/Listen.vue +++ b/front/src/components/activity/Listen.vue @@ -5,17 +5,20 @@
- - listened to a track - + + + +
{{ event.object.name }} - - - + + {{ event.object.album }} + {{ event.object.artist }} + + + {{ event.object.artist }} +
diff --git a/front/src/components/audio/PlayButton.vue b/front/src/components/audio/PlayButton.vue index f2a389862..14d381ca1 100644 --- a/front/src/components/audio/PlayButton.vue +++ b/front/src/components/audio/PlayButton.vue @@ -1,18 +1,18 @@ diff --git a/front/src/components/audio/track/Table.vue b/front/src/components/audio/track/Table.vue index 512ba1b49..7045cf9bd 100644 --- a/front/src/components/audio/track/Table.vue +++ b/front/src/components/audio/track/Table.vue @@ -4,9 +4,9 @@ - Title - Artist - Album + + + @@ -20,20 +20,18 @@ - + -
- Download tracks -
+
-

There is currently no way to download directly multiple tracks from funkwhale as a ZIP archive. - However, you can use a command line tools such as cURL to easily download a list of tracks. -

-

Simply copy paste the snippet below into a terminal to launch the download.

-
- Keep your PRIVATE_TOKEN secret as it gives access to your account. -
+ + cURL + + +
 export PRIVATE_TOKEN="{{ $store.state.auth.token }}"