Commit 3fc49958 authored by Alain St-Denis's avatar Alain St-Denis
Browse files

WIP: Fine tuning the translation process

parent 03c91863
......@@ -2,35 +2,40 @@ Requirements
------------
pybabel (already installed)
pip install django-babel (TODO: document my fix to extract.py)
pip install babel-vue-extractor
pip install django-babel
Create the initial pot file
---------------------------
Patch django-babel with (assuming you are using virtualenv):
```
patch -p1 ~/.virtualenvs/socialhome/lib/python3.9/site-packages/django_babel/extract < ~/socialhome/translate/django_babel.patch
```
TODO: create an issue for this
Workflow
--------
From project directory,
Create babel.cfg with the following content:
Create or update the pot file using:
```
[django: templates/**.*]
[django: socialhome/*/templates/**.*]
[python: socialhome/**.py]
[babelvueextractor.extract.extract_vue: socialhome/**.vue]
[javascript: socialhome/frontend/*.js]
[javascript: socialhome/frontend/src/**.js]
PYTHONPATH=. pybabel extract -F babel.cfg -o socialhome/locale/django.pot .
```
Extract initial pot file using:
Translations are hosted at https://hosted.weblate.org/projects/socialhome. During the initial setup, weblate will pull the django.pot file.
Then new translations can be started using weblate's UI. The pattern to configure for po files is socialhome/locale/*/LC_MESSAGES/django.po.
weblate can be configure to automatically compile mo files, but until we figure out how it works, use the following:
```
pybabel extract -F babel.cfg -o socialhome/locale/django.pot .
django-admin compilemessages
```
Saving and archiving from the weblate project will push the updated po files to socialhome's repository.
TODO
If changes to translation files (pot and po) are made, they should be pushed to the repo and then forced synced from weblate's UI.
Hack
----
Weblate setup.
~/socialhome/translate/extract.py is a wrapper around pybabel's javascript extractor to deal with template literal placehlders and filters.
Compile translations
--------------------
TODO: create an issue for this.
django-admin compilemessages
[extractors]
extrajs = translate.extract:extract_extrajs
[django: socialhome/templates/**.*]
[django: socialhome/*/templates/**.*]
[python: socialhome/**.py]
[babelvueextractor.extract.extract_vue: socialhome/**.vue]
[javascript: socialhome/frontend/*.js]
[javascript: socialhome/frontend/src/**.js]
#[javascript: socialhome/static/**.js]
[extrajs: socialhome/static/**.js]
import Vue from "vue"
import StreamElement from "@/components/streams/StreamElement.vue"
import PublicStampedElement from "@/components/streams/stamped_elements/PublicStampedElement.vue"
import FollowedStampedElement from "@/components/streams/stamped_elements/FollowedStampedElement.vue"
import LimitedStampedElement from "@/components/streams/stamped_elements/LimitedStampedElement.vue"
import LocalStampedElement from "@/components/streams/stamped_elements/LocalStampedElement.vue"
import TagStampedElement from "@/components/streams/stamped_elements/TagStampedElement.vue"
import TagsStampedElement from "@/components/streams/stamped_elements/TagsStampedElement.vue"
import ProfileStampedElement from "@/components/streams/stamped_elements/ProfileStampedElement.vue"
import LoadingElement from "@/components/common/LoadingElement.vue"
import ProfileStreamButtons from "@/components/streams/stamped_elements/ProfileStreamButtons"
export default Vue.component("Stream", {
components: {
FollowedStampedElement,
LimitedStampedElement,
LoadingElement,
LocalStampedElement,
ProfileStampedElement,
ProfileStreamButtons,
PublicStampedElement,
StreamElement,
TagStampedElement,
TagsStampedElement,
},
// TODO: Seperate Stream.vue into TagStream.vue, GuidProfile.vue and UsernameProfile.vue, etc. in the future
props: {
contentId: {
type: String, default: "",
},
uuid: {
type: String, default: "",
},
user: {
type: String, default: "",
},
tag: {
type: String, default: "",
},
},
data() {
return {
masonryOptions: {
"item-selector": ".grid-item",
"column-width": ".grid-sizer",
gutter: ".gutter-sizer",
"percent-position": true,
"transition-duration": "0s",
stagger: 0,
},
}
},
computed: {
singleContent() {
if (!this.$store.state.stream.singleContentId) {
return null
}
return this.$store.state.stream.contents[this.$store.state.stream.singleContentId]
},
showProfileStreamButtons() {
return this.streamName === "profile_all" || this.streamName === "profile_pinned"
},
stampedElement() {
switch (this.streamName) {
case "followed":
return "FollowedStampedElement"
case "limited":
return "LimitedStampedElement"
case "local":
return "LocalStampedElement"
case "public":
return "PublicStampedElement"
case "tag":
return "TagStampedElement"
case "tags":
return "TagsStampedElement"
case "profile_all":
case "profile_pinned":
return "ProfileStampedElement"
default:
// eslint-disable-next-line no-console
console.error(`Unsupported stream name ${this.streamName}`)
return ""
}
},
streamName() {
return this.$store.state.stream.stream.name
},
translations() {
const ln = this.unfetchedContentIds.length
s = ngettext(`${ln} new post available`, `${ln} new posts available`, ln)
return {newPostsAvailables: s}
},
unfetchedContentIds() {
return this.$store.state.stream.unfetchedContentIds
},
},
beforeMount() {
if (!this.$store.state.stream.stream.single) {
this.loadStream()
}
},
methods: {
onNewContentClick() {
this.$store.dispatch("stream/newContentAck").then(
() => this.$nextTick( // Wait for new content to be rendered
() => this.$scrollTo("body"),
),
)
},
loadStream() {
const options = {params: {}}
const lastContentId = this.$store.state.stream.currentContentIds[
this.$store.state.stream.currentContentIds.length - 1
]
if (lastContentId && this.$store.state.stream.contents[lastContentId]) {
options.params.lastId = this.$store.state.stream.contents[lastContentId].through
}
switch (this.$store.state.stream.stream.name) {
case "followed":
this.$store.dispatch("stream/getFollowedStream", options)
break
case "limited":
this.$store.dispatch("stream/getLimitedStream", options)
break
case "local":
this.$store.dispatch("stream/getLocalStream", options)
break
case "public":
this.$store.dispatch("stream/getPublicStream", options)
break
case "tag":
options.params.name = this.tag
this.$store.dispatch("stream/getTagStream", options)
break
case "tags":
this.$store.dispatch("stream/getTagsStream", options)
break
case "profile_all":
options.params.uuid = this.$store.state.application.profile.uuid
this.$store.dispatch("stream/getProfileAll", options)
break
case "profile_pinned":
options.params.uuid = this.$store.state.application.profile.uuid
this.$store.dispatch("stream/getProfilePinned", options)
break
default:
break
}
},
},
})
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-05-18 13:10+0000\n"
"POT-Creation-Date: 2021-05-21 18:06+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -37,27 +37,21 @@ msgstr ""
msgid "Privacy policy"
msgstr ""
#: socialhome/enums.py:21
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:11
#: socialhome/frontend/src/components/streams/stamped_elements/PublicStampedElement.vue:16
#: socialhome/enums.py:21 socialhome/static/dist/vue/js/app.js:67
#: socialhome/streams/enums.py:25 socialhome/templates/base.html:54
msgid "Public"
msgstr ""
#: socialhome/enums.py:22
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:16
#: socialhome/frontend/src/components/streams/stamped_elements/LimitedStampedElement.vue:15
#: socialhome/enums.py:22 socialhome/static/dist/vue/js/app.js:67
#: socialhome/streams/enums.py:21 socialhome/templates/base.html:50
msgid "Limited"
msgstr ""
#: socialhome/enums.py:23
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:21
#: socialhome/enums.py:23 socialhome/static/dist/vue/js/app.js:67
msgid "Site"
msgstr ""
#: socialhome/enums.py:24
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:26
#: socialhome/enums.py:24 socialhome/static/dist/vue/js/app.js:67
msgid "Self"
msgstr ""
......@@ -89,9 +83,7 @@ msgstr ""
#: socialhome/content/enums.py:18
#: socialhome/content/templates/content/_edit_title.html:7
#: socialhome/frontend/src/components/buttons/ReplyButton.vue:34
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:73
#: socialhome/frontend/src/components/streams/ReplyEditor.vue:57
#: socialhome/static/dist/vue/js/app.js:67
msgid "Reply"
msgstr ""
......@@ -99,8 +91,7 @@ msgstr ""
msgid "Share"
msgstr ""
#: socialhome/content/forms.py:18
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:70
#: socialhome/content/forms.py:18 socialhome/static/dist/vue/js/app.js:67
msgid "Recipients"
msgstr ""
......@@ -166,8 +157,7 @@ msgstr ""
msgid "Federation ID"
msgstr ""
#: socialhome/content/models.py:106
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:78
#: socialhome/content/models.py:106 socialhome/static/dist/vue/js/app.js:67
msgid "Pinned to profile"
msgstr ""
......@@ -179,13 +169,11 @@ msgstr ""
msgid "Service label"
msgstr ""
#: socialhome/content/models.py:115
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:83
#: socialhome/content/models.py:115 socialhome/static/dist/vue/js/app.js:67
msgid "Show OEmbed or OpenGraph preview"
msgstr ""
#: socialhome/content/models.py:116
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:84
#: socialhome/content/models.py:116 socialhome/static/dist/vue/js/app.js:67
msgid ""
"Disable to turn off fetching and showing an OEmbed or OpenGraph preview "
"using the links in the text."
......@@ -217,13 +205,11 @@ msgstr ""
msgid "Share of"
msgstr ""
#: socialhome/content/models.py:138
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:65
#: socialhome/content/models.py:138 socialhome/static/dist/vue/js/app.js:67
msgid "Federate to remote servers"
msgstr ""
#: socialhome/content/models.py:139
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:66
#: socialhome/content/models.py:139 socialhome/static/dist/vue/js/app.js:67
msgid ""
"Disable to skip federating this version to remote servers. Note, saved "
"content version will still be updated to local streams."
......@@ -233,12 +219,11 @@ msgstr ""
msgid "Limitied visibilities"
msgstr ""
#: socialhome/content/models.py:148
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:69
#: socialhome/content/models.py:148 socialhome/static/dist/vue/js/app.js:67
msgid "Include people I follow"
msgstr ""
#: socialhome/content/models.py:149
#: socialhome/content/models.py:149 socialhome/static/dist/vue/js/app.js:67
msgid "Automatically includes all the people you follow as recipients."
msgstr ""
......@@ -246,8 +231,7 @@ msgstr ""
msgid "Remote created"
msgstr ""
#: socialhome/content/models.py:159
#: socialhome/frontend/src/components/streams/stamped_elements/LocalStampedElement.vue:15
#: socialhome/content/models.py:159 socialhome/static/dist/vue/js/app.js:67
#: socialhome/streams/enums.py:22 socialhome/templates/base.html:53
msgid "Local"
msgstr ""
......@@ -273,18 +257,17 @@ msgid "This recipient couldn't be found (please check the format)."
msgstr ""
#: socialhome/content/templates/content/_edit_title.html:5
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:74
#: socialhome/static/dist/vue/js/app.js:67
msgid "Update reply"
msgstr ""
#: socialhome/content/templates/content/_edit_title.html:10
#: socialhome/frontend/src/components/streams/StreamElement.vue:79
#: socialhome/static/dist/vue/js/app.js:67
msgid "Update"
msgstr ""
#: socialhome/content/templates/content/_edit_title.html:12
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:63
#: socialhome/templates/base.html:59
#: socialhome/static/dist/vue/js/app.js:67 socialhome/templates/base.html:59
msgid "Create"
msgstr ""
......@@ -294,7 +277,7 @@ msgid "Confirm delete"
msgstr ""
#: socialhome/content/templates/content/delete.html:17
#: socialhome/frontend/src/components/streams/StreamElement.vue:78
#: socialhome/static/dist/vue/js/app.js:67
msgid "Delete"
msgstr ""
......@@ -310,441 +293,484 @@ msgstr ""
msgid "bookmarklet"
msgstr ""
#: socialhome/frontend/src/components/buttons/ShareButton.vue:30
msgid "unshare"
#: socialhome/notifications/tasks.py:59
#, python-format
msgid "New follower: %s"
msgstr ""
#: socialhome/frontend/src/components/buttons/ShareButton.vue:30
msgid "share"
#: socialhome/notifications/tasks.py:96
msgid "You have been mentioned"
msgstr ""
#: socialhome/frontend/src/components/common/ProfileReactionButtons.vue:72
#: socialhome/frontend/src/components/streams/stamped_elements/TagStampedElement.vue:55
#: socialhome/search/templates/search/search.html:48
#: socialhome/users/templates/users/_actions_column.html:5
msgid "Follow"
#: socialhome/notifications/tasks.py:130
#, python-format
msgid "New reply to: %s"
msgstr ""
#: socialhome/frontend/src/components/common/ProfileReactionButtons.vue:73
msgid "Home"
#: socialhome/notifications/tasks.py:168
#, python-format
msgid "New share of: %s"
msgstr ""
#: socialhome/frontend/src/components/common/ProfileReactionButtons.vue:74
#: socialhome/users/preferences.py:15
msgid "Profile"
#: socialhome/notifications/tasks.py:197
msgid "Data export is ready for download"
msgstr ""
#: socialhome/frontend/src/components/common/ProfileReactionButtons.vue:75
#: socialhome/frontend/src/components/streams/stamped_elements/TagStampedElement.vue:56
#: socialhome/search/templates/search/search.html:47
#: socialhome/users/templates/users/_actions_column.html:4
msgid "Unfollow"
#: socialhome/notifications/tasks.py:227
msgid "Important updates to our Terms of Service and Privacy Policy documents"
msgstr ""
#: socialhome/frontend/src/components/contacts/AppFollowers.vue:10
#: socialhome/users/views.py:234
msgid "Contacts - followers"
#: socialhome/notifications/tasks.py:229
msgid "Important updates to our Privacy Policy document"
msgstr ""
#: socialhome/frontend/src/components/contacts/AppFollowing.vue:10
#: socialhome/users/views.py:226
msgid "Contacts - following"
#: socialhome/notifications/tasks.py:231
msgid "Important updates to our Terms of Service document"
msgstr ""
#: socialhome/frontend/src/components/publisher/MarkdownEditor.vue:123
msgid "Toggle fullscreen (F11)"
#: socialhome/notifications/templates/notifications/base.html:11
#: socialhome/notifications/templates/notifications/base.txt:3
msgid "Dear"
msgstr ""
#: socialhome/frontend/src/components/publisher/MarkdownEditor.vue:124
msgid "Markdown guide"
#: socialhome/notifications/templates/notifications/base.html:18
#: socialhome/notifications/templates/notifications/base.txt:7
msgid "Wishing you a nice day"
msgstr ""
#: socialhome/frontend/src/components/publisher/MarkdownEditor.vue:125
msgid "Heading"
#: socialhome/notifications/templates/notifications/base.html:18
#: socialhome/notifications/templates/notifications/base.txt:8
#, python-format
msgid "The friendly %(site_name)s notifications robot"
msgstr ""
#: socialhome/frontend/src/components/publisher/MarkdownEditor.vue:126
#, python-format
msgid "The image %s couldn't be uploaded"
#: socialhome/notifications/templates/notifications/data_export.html:6
msgid "Your data export is ready for download."
msgstr ""
#: socialhome/frontend/src/components/publisher/MarkdownEditor.vue:127
msgid "add an image using an url (Ctrl-Alt-I)"
#: socialhome/notifications/templates/notifications/data_export.html:6
msgid "Download here"
msgstr ""
#: socialhome/frontend/src/components/publisher/MarkdownEditor.vue:128
msgid "Loading..."
#: socialhome/notifications/templates/notifications/data_export.txt:5
msgid "Your data export is ready for download:"
msgstr ""
#: socialhome/frontend/src/components/publisher/MarkdownEditor.vue:129
msgid "Insert image"
#: socialhome/notifications/templates/notifications/follow.html:6
#: socialhome/notifications/templates/notifications/follow.txt:5
msgid "You have a new follower:"
msgstr ""
#: socialhome/frontend/src/components/publisher/MarkdownEditor.vue:130
msgid "Toggle preview (Ctrl-P)"
#: socialhome/notifications/templates/notifications/mention.html:6
#: socialhome/notifications/templates/notifications/mention.txt:5
msgid "You have been mentioned by"
msgstr ""
#: socialhome/frontend/src/components/publisher/MarkdownEditor.vue:131
msgid ""
"You can upload images using the camera icon or by dragging them to the "
"text area. Valid file types: png/jpg/svg/gif."
#: socialhome/notifications/templates/notifications/mention.html:9
#: socialhome/notifications/templates/notifications/mention.txt:7
#: socialhome/notifications/templates/notifications/share.html:9
#: socialhome/notifications/templates/notifications/share.txt:7
msgid "Link to the content:"
msgstr ""
#: socialhome/frontend/src/components/publisher/MarkdownEditor.vue:133
msgid "Upload image"
#: socialhome/notifications/templates/notifications/policy_document_update.html:9
#: socialhome/notifications/templates/notifications/policy_document_update.txt:7
msgid "The changes have become effective at"
msgstr ""
#: socialhome/frontend/src/components/publisher/MarkdownEditor.vue:134
msgid "Toggle side by side (F9)"
#: socialhome/notifications/templates/notifications/policy_document_update.html:12
msgid "Please find the updated Terms of Service document"
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:12
msgid "visible to anyone, even anonymous users and internet search bots."
#: socialhome/notifications/templates/notifications/policy_document_update.html:12
#: socialhome/notifications/templates/notifications/policy_document_update.html:17
msgid "here"
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:17
msgid "visible to only those who shared with."
#: socialhome/notifications/templates/notifications/policy_document_update.html:17
msgid "Please find the updated Privacy Policy document"
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:22
#: socialhome/notifications/templates/notifications/policy_document_update.html:21
#: socialhome/notifications/templates/notifications/policy_document_update.txt:14
msgid ""
"visible to only users who are logged in. Does not federate to other "
"servers."
"No actions are required by you. By continuing to use the service you "
"accept the new document(s)."
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:27
msgid "visible to only self. Does not federate to other servers."
#: socialhome/notifications/templates/notifications/policy_document_update.txt:9
msgid "Please find the updated Terms of Service document at"
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:64
msgid "Edit"
#: socialhome/notifications/templates/notifications/policy_document_update.txt:12
msgid "Please find the updated Privacy Policy document at"
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:68
msgid "Hidden textarea"
#: socialhome/notifications/templates/notifications/reply.html:6
#: socialhome/notifications/templates/notifications/reply.txt:5
msgid "There is a new reply to content you have participated in by"
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:71
msgid ""
"Type in the handles (eg user@example.com) of the recipients. Separate by "
"commas. Sorry, no search yet.."
#: socialhome/notifications/templates/notifications/reply.html:9
#: socialhome/notifications/templates/notifications/reply.txt:7
msgid "React to the reply here:"
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:75
msgid "Visibility"
#: socialhome/notifications/templates/notifications/share.html:6
#: socialhome/notifications/templates/notifications/share.txt:5
msgid "Your content has received a new share by"
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:76
msgid ""
"Tip: You can use the \"Self\" visibility to create draft content and then"
" change the visibility to for example \"Public\" when you want to publish"
" it."
#: socialhome/search/views.py:136
msgid "Search string is invalid, please try another one."
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:79
msgid ""
"Pinned content will be shown on your personal profile in the order you "
"want. Reorder pinned content from the profile menu. Pinned content will "
"federate and otherwise function as any other content."
#: socialhome/search/templates/search/search.html:5
#: socialhome/search/templates/search/search.html:8
#: socialhome/search/templates/search/search.html:15
#: socialhome/templates/base.html:107 socialhome/templates/base.html:109
msgid "Search"
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:82
msgid "Error saving content."
#: socialhome/search/templates/search/search.html:12
msgid "Search term"
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:86
msgid ""
"When visibility is set to 'Limited', you must either specify recipients "
"or include your followers."
#: socialhome/search/templates/search/search.html:13
msgid "Type a search term"
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:88
msgid "Some recipients couldn't be found."
#: socialhome/search/templates/search/search.html:22
msgid "Profiles"
msgstr ""
#: socialhome/frontend/src/components/publisher/publisher-mixin.js:89
msgid "Validation error"
#: socialhome/search/templates/search/search.html:47
#: socialhome/static/dist/vue/js/app.js:67
#: socialhome/users/templates/users/_actions_column.html:4
msgid "Unfollow"
msgstr ""
#: socialhome/frontend/src/components/streams/ReactionsBar.vue:123
msgid "Replies"
#: socialhome/search/templates/search/search.html:48
#: socialhome/static/dist/vue/js/app.js:67
#: socialhome/users/templates/users/_actions_column.html:5
msgid "Follow"
msgstr ""
#: socialhome/frontend/src/components/streams/ReactionsBar.vue:124
msgid "Shares"
#: socialhome/search/templates/search/search.html:55
#: socialhome/search/templates/search/search.html:85
msgid "No results found."
msgstr ""
#: socialhome/search/templates/search/search.html:61
msgid "Previous"
msgstr ""