Skip to content

Node.js based forum software built for the modern web

Replace hardcoded intent display names with translation keys

Julian Lam900fde059d53
diff --git a/public/language/en-GB/intents.json b/public/language/en-GB/intents.json
index 4e5e92b113..6135bffac1 100644
--- a/public/language/en-GB/intents.json
+++ b/public/language/en-GB/intents.json
@@ -1,4 +1,9 @@
{
+ "display.create": "Create & Reply",
+ "display.like": "Upvote",
+ "display.dislike": "Downvote",
+ "display.follow": "Follow",
+ "display.object": "View",
"title": "Register Open Social Web Handle",
"description": "Enter your Open Social Web handle to register for Activity Intents. This will allow you to share content from this forum to your social profile.",
"handle-label": "Open Social Web Handle",
diff --git a/public/src/modules/intents.js b/public/src/modules/intents.js
index 2de6fd1ae7..ca895a4cda 100644
--- a/public/src/modules/intents.js
+++ b/public/src/modules/intents.js
@@ -24,15 +24,18 @@ function setStoredData(data) {
}
const INTENT_DISPLAY_MAP = {
- create: 'Create & Reply',
- like: 'Upvote',
- dislike: 'Downvote',
- follow: 'Follow',
- object: 'View',
+ create: 'intents:display.create',
+ like: 'intents:display.like',
+ dislike: 'intents:display.dislike',
+ follow: 'intents:display.follow',
+ object: 'intents:display.object',
};
function mapIntentNames(intents) {
- return Object.keys(intents).map(intent => INTENT_DISPLAY_MAP[intent.toLowerCase()] || intent);
+ return Object.keys(intents).map(intent => {
+ const key = INTENT_DISPLAY_MAP[intent.toLowerCase()];
+ return app.parseAndTranslate(key || intent);
+ });
}
export function list() {
@@ -193,7 +196,8 @@ function _intentsHandler(e) {
export function trigger(intent, parameters) {
const map = list();
const requiredIntent = intent.toLowerCase();
- const displayIntent = INTENT_DISPLAY_MAP[requiredIntent] || intent;
+ const displayKey = INTENT_DISPLAY_MAP[requiredIntent];
+ const displayIntent = app.parseAndTranslate(displayKey || intent);
const entries = Array.from(map.entries()).map(([handle, intents]) => ({ handle, intents }));
const matchingHandles = entries