Commit 76f2b664 authored by JC Brand's avatar JC Brand

Add a po loader for webpack.

- Removes the need for generating and keeping json files
parent 8aaf50d5
......@@ -2,10 +2,13 @@
## 5.0.2 (Unreleased)
- `po` translations files are now loaded via Webpack. As a result the `locales_url`
config option is now removed given that the path to the locale JSON files is now
determined by the webpack config and can't be changed at runtime.
- The JSON representing emojis is now fetched asynchronously as a separate file `converse.emojis.js`.
- Webpack is now configured with a `publicPath` set to `/dist/`. This is necessary
so that chunks (such as the Emojis JSON) can be fetched asynchronously. This
means that all your assets need to be served at `/dist`. If you need to set a
so that chunks (such as the emojis and locales JSON files) can be fetched asynchronously.
This means that all your assets need to be served at `/dist`. If you need to set a
different path, you'll need to set `publicPath` in `webpack.config.js` to
your preferred path and then rebuild all assets (e.g. `make dist`).
......
......@@ -14,7 +14,6 @@ JSDOC ?= ./node_modules/.bin/jsdoc
LERNA ?= ./node_modules/.bin/lerna
OXIPNG ?= oxipng
PAPER =
PO2JSON ?= ./node_modules/.bin/po2json
RJS ?= ./node_modules/.bin/r.js
NPX ?= ./node_modules/.bin/npx
SASS ?= ./node_modules/.bin/node-sass
......@@ -43,7 +42,6 @@ help:
@echo " dev Set up the development environment. To force a fresh start, run 'make clean' first."
@echo " html Make standalone HTML files of the documentation."
@echo " po Generate gettext PO files for each i18n language."
@echo " po2json Generate JSON files from the language PO files."
@echo " pot Generate a gettext POT file to be used for translations."
@echo " release Prepare a new release of converse.js. E.g. make release VERSION=0.9.5"
@echo " serve Serve this directory via a webserver on port 8000."
......@@ -77,10 +75,6 @@ pot: dist/converse-no-dependencies-es2015.js
po:
find ./locale -maxdepth 1 -mindepth 1 -type d -exec msgmerge {}/LC_MESSAGES/converse.po ./locale/converse.pot -U \;
.PHONY: po2json
po2json:
find ./locale -maxdepth 1 -mindepth 1 -type d -exec $(PO2JSON) -f jed1.x -d converse {}/LC_MESSAGES/converse.po {}/LC_MESSAGES/converse.json \;
########################################################################
## Release management
......@@ -99,7 +93,6 @@ release:
$(SED) -ri 's,cdn.conversejs.org/$(VERSION_FORMAT),cdn.conversejs.org/$(VERSION),' demo/*.html
make pot
make po
make po2json
make build
npm pack
......
......@@ -747,14 +747,13 @@ i18n
Specify the locale/language.
The translations for that locale must be available in JSON format at the
`locales_url`_
The translations for that locale must be served in JSON format at `/dist/locales/${i18n}-LC_MESSAGES-converse-po.js`.
The default webpack configuration for Converse.js ensures that these files are
generated and placed in the right location.
If an explicit locale is specified via the ``i18n`` setting and the
translations for that locale are not found at the `locales_url``, then
then Converse will fall back to trying to determine the browser's language
and fetching those translations, or if that fails the default English texts
will be used.
translations for that locale are not found, then Converse will fall back to trying to determine the browser's language
and fetching those translations, or if that fails the default English strings will be used.
idle_presence_timeout
---------------------
......@@ -812,34 +811,6 @@ Any other locales will be ignored.
When self-hosting, also make sure that the locales are served and therefore
fetchable (via ``XMLHttpRequest``) at the URL specified by :ref:`locales-url`.
.. _`locales-url`:
locales_url
-----------
* Default: ``/locale/{{{locale}}}/LC_MESSAGES/converse.json``,
The URL from where Converse should fetch translation JSON.
The three curly braces ``{{{ }}}`` are
`Mustache <https://github.com/janl/mustache.js#readme>`_-style
variable interpolation which HTML-escapes the value being inserted. It's
important that the inserted value is HTML-escaped, otherwise a malicious script
injection attack could be attempted.
The variable being interpolated via the curly braces is ``locale``, which is
the value passed in to the `i18n`_ setting, or the browser's locale or the
default local or ``en`` (resolved in that order).
From version 3.3.0, Converse no longer bundles all translations into its
final build file. Instead, only the relevant translations are fetched at
runtime.
This change also means that it's no longer possible to pass in the translation
JSON data directly into ``_converse.initialize`` via the `i18n`_ setting.
Instead, you only specify the language code (e.g. `de`) and that language's
JSON translations will automatically be fetched via XMLHTTPRequest at
``locales_url``.
locked_domain
-------------
......
......@@ -18,7 +18,7 @@
<!-- *********************************************************************** -->
<![if gte IE 11]>
<link type="text/css" rel="stylesheet" media="screen" href="https://cdn.conversejs.org/5.0.1/dist/converse.min.css" />
<link type="text/css" rel="stylesheet" media="screen" href="/dist/converse.min.css" />
<script src="https://cdn.conversejs.org/3rdparty/libsignal-protocol.min.js"></script>
<script src="https://cdn.conversejs.org/5.0.1/dist/converse.min.js"></script>
<![endif]>
......
This diff is collapsed.
......@@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: Converse.js 0.4\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-14 12:46+0200\n"
"PO-Revision-Date: 2019-08-14 12:42+0200\n"
"PO-Revision-Date: 2019-08-23 10:16+0200\n"
"Last-Translator: JC Brand <jc@opkode.com>\n"
"Language-Team: Afrikaans <https://hosted.weblate.org/projects/conversejs/"
"translations/af/>\n"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{"domain":"converse","locale_data":{"converse":{"":{"domain":"converse","plural_forms":"nplurals=1; plural=0;","lang":"id"},"The name for this bookmark:":["Nama untuk penanda ini:"],"Error":["Kesalahan"],"Message":["Pesan"],"Optional hint":[""],"Choose a file to send":[""],"Clear all messages":["Hapus semua pesan"],"Message characters remaining":[""],"Remove messages":["Hapus pesan"],"Show this menu":["Tampilkan menu ini"],"You have an unsent message which will be lost if you continue. Are you sure?":[""],"Username":["Nama pengguna"],"user@domain":[""],"Please enter a valid XMPP address":[""],"Toggle chat":[""],"Typing from another device":["Mengetik dari perangkat lain"],"Description:":["Deskripsi:"],"Features:":["Fitur:"],"Requires authentication":["Membutuhkan otentikasi"],"Hidden":["Tersembunyi"],"Requires an invitation":["Membutuhkan undangan"],"Moderated":["Dimoderasi"],"Non-anonymous":["Tidak anonim"],"Public":["Umum"],"Semi-anonymous":["Semi-anonim"],"Unmoderated":["Tidak dimoderasi"],"Affiliation changed":[""],"Role changed":[""],"name@conference.example.org":[""],"Groupchat info for %1$s":[""],"Forbidden: you do not have the necessary role in order to do that.":[""],"Forbidden: you do not have the necessary affiliation in order to do that.":[""],"Error: the \"%1$s\" command takes two arguments, the user's nickname and optionally a reason.":[""],"Error: couldn't find a groupchat participant based on your arguments":[""],"Error: found multiple groupchat participant based on your arguments":[""],"Sorry, an error happened while running the command. Check your browser's developer console for details.":[""],"You can run the following commands":[""],"Ban user by changing their affiliation to outcast":[""],"Grant membership to a user":[""],"Opens up the moderator tools GUI":[""],"Remove user's ability to post messages":[""],"Change your nickname":[""],"Grant moderator role to user":[""],"Revoke the user's current affiliation":[""],"Set groupchat subject (alias for /subject)":[""],"Allow muted user to post messages":[""],"Error: invalid number of arguments":[""],"The reason given is: \"%1$s\".":[""],"Groupchats":[""],"Password: ":["Kata sandi: "],"Submit":["Kirim"],"Please choose your nickname":[""],"Nickname":["Nama panggilan"],"You need to provide a nickname":[""],"Visitor":[""],"Owner":[""],"Member":[""],"Admin":[""],"Participants":[""],"Invite":[""],"You are about to invite %1$s to the groupchat \"%2$s\". You may optionally include a message, explaining the reason for the invitation.":[""],"Notification from %1$s":[""],"%1$s says":[""],"OMEMO Message received":[""],"wants to be your contact":[""],"Are you sure you want to generate new OMEMO keys? This will remove your old keys and all previously encrypted messages will no longer be decryptable on this device.":[""],"Sorry, could not decrypt a received OMEMO message due to an error.":[""],"Sorry, we're unable to send an encrypted message because %1$s requires you to be subscribed to their presence in order to see their OMEMO information":[""],"Sorry, we're unable to send an encrypted message because the remote server for %1$s could not be found":[""],"Unable to send an encrypted message due to an unexpected error.":[""],"Cannot use end-to-end encryption in this groupchat, either the groupchat has some anonymity or not all participants support OMEMO.":[""],"Cannot use end-to-end encryption because %1$s uses a client that doesn't support OMEMO.":[""],"Sorry, no devices found to which we can send an OMEMO encrypted message.":[""],"This is an OMEMO encrypted message which your client doesn’t seem to support. Find more information on https://conversations.im/omemo":[""],"%1$s doesn't appear to have a client that supports OMEMO. Encrypted chat will no longer be possible in this grouchat.":[""],"Your avatar image":[""],"Your Profile":[""],"Close":[""],"Email":[""],"Full Name":[""],"XMPP Address (JID)":[""],"Role":[""],"Use commas to separate multiple roles. Your roles are shown next to your name on your chat messages.":[""],"URL":[""],"You can check your browser's developer console for any error output.":[""],"Busy":["Sibuk"],"Offline":["Tidak Terhubung"],"Online":["Terhubung"],"About":[""],"%1$s Open Source %2$s XMPP chat client brought to you by %3$s Opkode %2$s":[""],"%1$s Translate %2$s it into your own language":[""],"I am %1$s":["Saya %1$s"],"Change settings":[""],"Click to change your chat status":["Klik untuk mengganti status obrolan"],"Your profile":[""],"online":["terhubung"],"busy":["sibuk"],"offline":["tidak terhubung"]," e.g. conversejs.org":[""],"Fetch registration form":[""],"Tip: A list of public XMPP providers is available":[""],"here":[""],"Sorry, we're unable to connect to your chosen provider.":[""],"Sorry, the given provider does not support in band account registration. Please try with a different provider.":[""],"Something went wrong while establishing a connection with \"%1$s\". Are you sure it exists?":[""],"Now logging you in":[""],"Registered successfully":[""],"The provider rejected your registration attempt. Please check the values you entered for correctness.":[""],"Open Groupchats":[""],"This contact is busy":["Kontak ini sedang sibuk"],"This contact is online":["Kontak ini terhubung"],"This contact is offline":["Kontak ini tidak terhubung"],"This contact is unavailable":["Kontak ini tidak tersedia"],"This contact is away":["Kontak ini sedang pergi"],"Groups":[""],"Optional nickname":[""],"XMPP Address":[""],"Add":["Tambah"],"Sorry, could not find a contact with that name":[""],"Filter":[""],"Filter by group name":[""],"Filter by status":[""],"Any":[""],"Unread":[""],"Chatty":[""],"Extended Away":[""],"Unencryptable OMEMO message":[""],"Sorry, could not determine upload URL.":[""],"Sorry, could not determine file upload URL.":[""],"Sorry, could not succesfully upload your file. Your server’s response: \"%1$s\"":[""],"Sorry, could not succesfully upload your file.":[""],"Sorry, looks like file upload is not supported by your server.":[""],"The size of your file, %1$s, exceeds the maximum allowed by your server, which is %2$s.":[""],"Sorry, an error occurred:":[""],"The connection has dropped, attempting to reconnect.":["Sambungan terputus, mencoba menyambungkan kembali"],"Your Jabber ID and/or password is incorrect. Please try again.":["username dan/atau password Anda salah. Silahkan ulang kembali."],"Sorry, we could not connect to the XMPP host with domain: %1$s":["Maaf, Domain: %1$s tidak dapat tersambung ke XMPP host kami"],"The XMPP server did not offer a supported authentication mechanism":[""],"Can't register your nickname in this groupchat, it doesn't support registration.":[""],"Can't register your nickname in this groupchat, invalid data form supplied.":[""],"The nickname you chose is reserved or currently in use, please choose a different one.":[""],"Remote server not found":[""],"The explanation given is: \"%1$s\".":[""],"%1$s has invited you to join a groupchat: %2$s, and left the following reason: \"%3$s\"":[""],"My contacts":["Kontak saya"],"Pending contacts":["Kontak yang tertunda"],"Contact requests":["Permintaan pertemanan"],"Ungrouped":[""],"Sorry, there was an error while trying to add %1$s as a contact.":["Maaf, ada sesuatu kesalahan saat mencoba menambahkan %1$s sebagai kontak"],"This field is required":[""],"The conversation has moved. Click below to enter.":[""],"Name":[""],"Topic":[""],"Topic author":[""],"Members only":[""],"Persistent":[""],"This groupchat persists even if it's unoccupied":[""],"This groupchat will disappear once the last person leaves":[""],"All other groupchat participants can see your XMPP address":[""],"Only moderators can see your XMPP address":[""],"Participants entering this groupchat need to request permission to write":[""],"Participants entering this groupchat can write right away":[""],"Message archiving":[""],"Messages are archived on the server":[""],"Uploading file:":[""],"XMPP Address:":[""],"Password:":["Kata sandi:"],"password":["kata sandi"],"This is a trusted device":[""],"To improve performance, we cache your data in this browser. Uncheck this box if this is a public computer or if you want your data to be deleted when you log out. It's important that you explicitly log out, otherwise not all cached data might be deleted. Please note, when using an untrusted device, OMEMO encryption is NOT available.":[""],"New Role":[""],"Reason":[""],"Change role":[""],"Affiliation":[""],"No users with that affiliation found.":[""],"New affiliation":[""],"Save and close":[""],"This device's OMEMO fingerprint":[""],"Generate new keys and fingerprint":[""],"Select all":[""],"Checkbox to select fingerprints of all other OMEMO devices":[""],"Other OMEMO-enabled devices":[""],"Checkbox for selecting the following fingerprint":[""],"Remove checked devices and close":[""],"Don't have a chat account?":[""],"Create an account":[""],"Create your account":[""],"Please enter the XMPP provider to register with:":[""],"Already have a chat account?":[""],"Log in here":[""],"Account Registration:":[""],"Register":[""],"Choose a different provider":[""],"Hold tight, we're fetching the registration form…":[""],"Messages are being sent in plaintext":[""],"The User's Profile Image":[""],"Full Name:":[""],"URL:":[""],"Email:":[""],"Role:":[""],"OMEMO Fingerprints":[""],"Trusted":[""],"Untrusted":[""],"Refresh":[""],"Download":["Unduh"]}}}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: Converse.js 4.2.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-14 12:46+0200\n"
"PO-Revision-Date: 2019-08-06 14:23+0000\n"
"PO-Revision-Date: 2019-08-23 10:17+0200\n"
"Last-Translator: Quentí <quentinantonin@free.fr>\n"
"Language-Team: Occitan <https://hosted.weblate.org/projects/conversejs/"
"translations/oc/>\n"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -6187,12 +6187,42 @@
}
},
"gettext-parser": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-1.1.0.tgz",
"integrity": "sha1-LFpmONiTk0ubVQN9CtgstwBLJnk=",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-2.0.0.tgz",
"integrity": "sha512-FDs/7XjNw58ToQwJFO7avZZbPecSYgw8PBYhd0An+4JtZSrSzKhEvTsVV2uqdO7VziWTOGSgLGD5YRPdsCjF7Q==",
"dev": true,
"requires": {
"encoding": "^0.1.12",
"safe-buffer": "^5.1.2"
},
"dependencies": {
"safe-buffer": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
"integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==",
"dev": true
}
}
},
"gettext-to-messageformat": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/gettext-to-messageformat/-/gettext-to-messageformat-0.3.0.tgz",
"integrity": "sha512-HlEGFECqAavbOYJTo1I2qh8IqWetAenixaH/AbdIuNTY0easvzrPn+yYUHy63GEjx9pXoLx2nCJcDcE27LrB2g==",
"dev": true,
"requires": {
"encoding": "^0.1.11"
"gettext-parser": "^1.3.0"
},
"dependencies": {
"gettext-parser": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-1.4.0.tgz",
"integrity": "sha512-sedZYLHlHeBop/gZ1jdg59hlUEcpcZJofLq2JFwJT1zTqAU3l2wFv6IsuwFHGqbiT9DWzMUW4/em2+hspnmMMA==",
"dev": true,
"requires": {
"encoding": "^0.1.12",
"safe-buffer": "^5.1.1"
}
}
}
},
"git-raw-commits": {
......@@ -6482,12 +6512,6 @@
"ansi-regex": "^2.0.0"
}
},
"has-color": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz",
"integrity": "sha1-ZxRKUmDDT8PMpnfQQdr1L+e3iy8=",
"dev": true
},
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
......@@ -8590,47 +8614,6 @@
}
}
},
"nomnom": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.8.1.tgz",
"integrity": "sha1-IVH3Ikcrp55Qp2/BJbuMjy5Nwqc=",
"dev": true,
"requires": {
"chalk": "~0.4.0",
"underscore": "~1.6.0"
},
"dependencies": {
"ansi-styles": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.0.0.tgz",
"integrity": "sha1-yxAt8cVvUSPquLZ817mAJ6AnkXg=",
"dev": true
},
"chalk": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-0.4.0.tgz",
"integrity": "sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=",
"dev": true,
"requires": {
"ansi-styles": "~1.0.0",
"has-color": "~0.1.0",
"strip-ansi": "~0.1.0"
}
},
"strip-ansi": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.1.1.tgz",
"integrity": "sha1-OeipjQRNFQZgq+SmgIrPcLt7yZE=",
"dev": true
},
"underscore": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz",
"integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=",
"dev": true
}
}
},
"nopt": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz",
......@@ -12437,14 +12420,60 @@
"lodash": "^4.17.11"
}
},
"po-loader": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/po-loader/-/po-loader-0.5.0.tgz",
"integrity": "sha512-2VyoECqHL6pLUxQqszi9WskwOgRPtO3y+fhVmYMb46L+5S03whRf/lHqWhbTE3AbwEc6DdPuGKFD4IUbWuM/YQ==",
"dev": true,
"requires": {
"loader-utils": "^1.2.3"
},
"dependencies": {
"big.js": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
"integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==",
"dev": true
},
"json5": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
}
},
"loader-utils": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz",
"integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==",
"dev": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^2.0.0",
"json5": "^1.0.1"
}
}
}
},
"po2json": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/po2json/-/po2json-0.4.5.tgz",
"integrity": "sha1-R7spUtoy1Yob4vJWpZjuvAt0URg=",
"version": "1.0.0-alpha",
"resolved": "https://registry.npmjs.org/po2json/-/po2json-1.0.0-alpha.tgz",
"integrity": "sha512-DsP/L4JsMB/gTEpXm9B1I+S1W0z0wNXu4Ky47MUlfS3ruwUZT1nUm+FvWt+ZMehFTh1EcXAhx6oljw8Ly4qTaA==",
"dev": true,
"requires": {
"gettext-parser": "1.1.0",
"nomnom": "1.8.1"
"commander": "^2.18.0",
"gettext-parser": "2.0.0",
"gettext-to-messageformat": "^0.3.0"
},
"dependencies": {
"commander": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz",
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==",
"dev": true
}
}
},
"portfinder": {
......
......@@ -237,7 +237,6 @@ _converse.default_settings = {
idle_presence_timeout: 300, // Seconds after which an idle presence is sent
jid: undefined,
keepalive: true,
locales_url: '/locale/{{{locale}}}/LC_MESSAGES/converse.json',
locales: [
'af', 'ar', 'bg', 'ca', 'cs', 'de', 'eo', 'es', 'eu', 'en', 'fr', 'gl',
'he', 'hi', 'hu', 'id', 'it', 'ja', 'nb', 'nl', 'oc',
......@@ -1336,9 +1335,8 @@ _converse.initialize = async function (settings, callback) {
await finishInitialization();
return _converse;
} else if (i18n !== undefined) {
const url = u.interpolate(_converse.locales_url, {'locale': _converse.locale});
try {
await i18n.fetchTranslations(_converse.locale, _converse.locales, url);
await i18n.fetchTranslations(_converse.locale, _converse.locales);
} catch (e) {
_converse.log(e.message, Strophe.LogLevel.FATAL);
}
......
......@@ -129,37 +129,12 @@ export default {
* @method i18n#fetchTranslations
* @param { String } locale -The given i18n locale
* @param { Array } supported_locales - List of locales supported
* @param { String } locale_url - The URL from which the translations should be fetched
*/
fetchTranslations (locale, supported_locales, locale_url) {
return new Promise((resolve, reject) => {
if (!isConverseLocale(locale, supported_locales) || locale === 'en') {
return resolve();
}
const xhr = new XMLHttpRequest();
xhr.open('GET', locale_url, true);
xhr.setRequestHeader(
'Accept',
"application/json, text/javascript"
);
xhr.onload = function () {
if (xhr.status >= 200 && xhr.status < 400) {
try {
const data = window.JSON.parse(xhr.responseText);
jed_instance = new Jed(data);
resolve();
} catch (e) {
xhr.onerror(e);
}
} else {
xhr.onerror();
}
};
xhr.onerror = (e) => {
const err_message = e ? ` Error: ${e.message}` : '';
reject(new Error(`Could not fetch translations. Status: ${xhr.statusText}. ${err_message}`));
}
xhr.send();
});
async fetchTranslations (locale, supported_locales) {
if (!isConverseLocale(locale, supported_locales) || locale === 'en') {
return;
}
const { default: data } = await import(/*webpackChunkName: "locales/[request]" */ `../../locale/${locale}/LC_MESSAGES/converse.po`);
jed_instance = new Jed(data);
}
};
......@@ -14,7 +14,7 @@ const config = {
path: path.resolve(__dirname, 'dist'), // Output path for generated bundles
publicPath: '/dist/', // URL base path for all assets
filename: 'converse.js',
chunkFilename: 'converse.[name].js'
chunkFilename: '[name].js'
},
devtool: 'source-map',
plugins: [new MiniCssExtractPlugin({filename: '../dist/converse.css'})],
......@@ -46,6 +46,19 @@ const config = {
"prependFilenameComment": __dirname
}
}]
}, {
test: /LC_MESSAGES\/converse.po$/,
type: "json",
use: [
{
loader: 'po-loader',
options: {
'format': 'jed',
'domain': 'converse'
}
}
]
}, {
}, {
test: /webfonts\/.*\.(woff(2)?|ttf|eot|truetype|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment