git ssb

10+

Matt McKegg / patchwork



Commit 3d5a912d4f26780685c60d2ccc930cd6dd9567cc

i18n + more translations

Joran authored on 4/27/2017, 11:07:03 PM
Marcos Gutierrez committed on 9/29/2017, 12:59:36 PM
Parent: 771e58efb5920f3b771f41b4c98a7905a56975ee

Files changed

index.jschanged
lib/window.jschanged
lib/i18n.jsadded
main-window.jschanged
modules/app/html/search.jschanged
modules/feed/html/rollup.jschanged
modules/page/html/render/public.jschanged
package.jsonchanged
server-process.jschanged
locales/en.jsonadded
locales/ki.jsonadded
index.jsView
@@ -2,8 +2,10 @@
22 console.log(err)
33 process.exit()
44 })
55
6+var i18n = require('./lib/i18n').i18n
7+
68 var electron = require('electron')
79 var openWindow = require('./lib/window')
810
911 var Path = require('path')
@@ -18,8 +20,9 @@
1820 }
1921 var ssbConfig = null
2022 var quitting = false
2123
24+
2225 electron.app.on('ready', () => {
2326 setupContext('ssb', {
2427 server: !(process.argv.includes('-g') || process.argv.includes('--use-global-ssb'))
2528 }, () => {
@@ -79,9 +82,9 @@
7982 width: windowState.width,
8083 height: windowState.height,
8184 titleBarStyle: 'hidden-inset',
8285 autoHideMenuBar: true,
83- title: 'Patchwork',
86+ title: i18n.__("Patchwork"),
8487 show: true,
8588 backgroundColor: '#EEE',
8689 webPreferences: {
8790 experimentalFeatures: true
lib/window.jsView
@@ -18,9 +18,9 @@
1818 electron.webFrame.setZoomLevelLimits(1, 1)
1919
2020 var config = ${JSON.stringify(config)}
2121 var data = ${JSON.stringify(opts.data)}
22- var title = ${JSON.stringify(opts.title || 'Patchwork')}
22+ var title = ${JSON.stringify(opts.title || i18n.__("Patchwork"))}
2323
2424 document.documentElement.querySelector('head').appendChild(
2525 h('title', title)
2626 )
lib/i18n.jsView
@@ -1,0 +1,12 @@
1+// Multi Language support
2+var appRoot = require('app-root-path');
3+
4+var i18n = require("i18n")
5+i18n.configure({
6+ locales:['en','ki'],
7+ directory: appRoot + '/locales'
8+});
9+
10+i18n.setLocale('ki')
11+
12+exports.i18n = i18n;
main-window.jsView
@@ -11,9 +11,11 @@
1111 var LatestUpdate = require('./lib/latest-update')
1212 var ref = require('ssb-ref')
1313 var setupContextMenuAndSpellCheck = require('./lib/context-menu-and-spellcheck')
1414 var watch = require('mutant/watch')
15+var i18n = require('./lib/i18n').i18n
1516
17+
1618 module.exports = function (config) {
1719 var sockets = combine(
1820 overrideConfig(config),
1921 addCommand('app.navigate', setView),
@@ -90,10 +92,10 @@
9092 classList: [ when(views.canGoForward, '-active') ]
9193 })
9294 ]),
9395 h('span.nav', [
94- tab('Public', '/public'),
95- tab('Private', '/private'),
96+ tab(i18n.__("Public"), '/public'),
97+ tab(i18n.__("Private"), '/private'),
9698 dropTab('More', [
9799 getSubscribedChannelMenu,
98100 ['Gatherings', '/gatherings'],
99101 ['Extended Network', '/all'],
@@ -101,15 +103,15 @@
101103 ['Settings', '/settings']
102104 ])
103105 ]),
104106 h('span.appTitle', [
105- h('span.title', 'Patchwork'),
107+ h('span.title', i18n.__("Patchwork")),
106108 api.app.html.progressNotifier()
107109 ]),
108110 h('span', [ api.app.html.search(api.app.navigate) ]),
109111 h('span.nav', [
110- tab('Profile', id),
111- tab('Mentions', '/mentions')
112+ tab(i18n.__('Profile'), id),
113+ tab(i18n.__('Mentions'), '/mentions')
112114 ])
113115 ]),
114116 when(latestUpdate,
115117 h('div.info', [
modules/app/html/search.jsView
@@ -1,8 +1,12 @@
11 var h = require('mutant/h')
22 var nest = require('depnest')
33 var addSuggest = require('suggest-box')
44
5+var appRoot = require('app-root-path');
6+var i18n = require(appRoot + '/lib/i18n').i18n
7+
8+
59 exports.needs = nest({
610 'profile.async.suggest': 'first',
711 'channel.async.suggest': 'first'
812 })
@@ -16,9 +20,9 @@
1620 var getProfileSuggestions = api.profile.async.suggest()
1721 var getChannelSuggestions = api.channel.async.suggest()
1822 var searchBox = h('input.search', {
1923 type: 'search',
20- placeholder: 'word, @key, #channel',
24+ placeholder: i18n.__('word, @key, #channel'),
2125 'ev-suggestselect': (ev) => {
2226 setView(ev.detail.id)
2327 searchBox.value = ev.detail.id
2428 },
modules/feed/html/rollup.jsView
@@ -17,8 +17,12 @@
1717
1818 // bump even for first message
1919 var rootBumpTypes = ['mention', 'channel-mention']
2020
21+var appRoot = require('app-root-path');
22+var i18n = require(appRoot + '/lib/i18n').i18n
23+
24+
2125 exports.needs = nest({
2226 'about.obs.name': 'first',
2327 'app.sync.externalHandler': 'first',
2428 'message.html.render': 'first',
@@ -46,9 +50,9 @@
4650 var updates = Value(0)
4751 var yourId = api.keys.sync.id()
4852 var throttledUpdates = throttle(updates, 200)
4953 var updateLoader = h('a Notifier -loader', { href: '#', 'ev-click': refresh }, [
50- 'Show ', h('strong', [throttledUpdates]), ' ', plural(throttledUpdates, 'update', 'updates')
54+ 'Show ', h('strong', [throttledUpdates]), ' ', plural(throttledUpdates, i18n.__('update'), i18n.__('updates'))
5155 ])
5256
5357 var abortLastFeed = null
5458 var content = Value()
@@ -253,27 +257,27 @@
253257 if (ids.length > 4) {
254258 return [
255259 fn(featuredIds[0]), ', ',
256260 fn(featuredIds[1]), ', ',
257- fn(featuredIds[2]), ' and ',
258- ids.length - 3, ' others'
261+ fn(featuredIds[2]), i18n.__(' and '),
262+ ids.length - 3, i18n.__(' others')
259263 ]
260264 } else if (ids.length === 4) {
261265 return [
262266 fn(featuredIds[0]), ', ',
263267 fn(featuredIds[1]), ', ',
264- fn(featuredIds[2]), ' and ',
268+ fn(featuredIds[2]), i18n.__(' and '),
265269 fn(featuredIds[3])
266270 ]
267271 } else if (ids.length === 3) {
268272 return [
269273 fn(featuredIds[0]), ', ',
270- fn(featuredIds[1]), ' and ',
274+ fn(featuredIds[1]), i18n.__(' and '),
271275 fn(featuredIds[2])
272276 ]
273277 } else if (ids.length === 2) {
274278 return [
275- fn(featuredIds[0]), ' and ',
279+ fn(featuredIds[0]), i18n.__(' and '),
276280 fn(featuredIds[1])
277281 ]
278282 } else {
279283 return fn(featuredIds[0])
modules/page/html/render/public.jsView
@@ -3,8 +3,12 @@
33 var pull = require('pull-stream')
44 var normalizeChannel = require('../../../../lib/normalize-channel')
55 var { h, send, when, computed, map } = require('mutant')
66
7+var appRoot = require('app-root-path');
8+var i18n = require(appRoot + '/lib/i18n').i18n
9+
10+
711 exports.needs = nest({
812 sbot: {
913 obs: {
1014 connectedPeers: 'first',
@@ -52,9 +56,9 @@
5256 var localPeers = api.sbot.obs.localPeers()
5357 var connectedPubs = computed([connectedPeers, localPeers], (c, l) => c.filter(x => !l.includes(x)))
5458
5559 var prepend = [
56- api.message.html.compose({ meta: { type: 'post' }, placeholder: 'Write a public message' })
60+ api.message.html.compose({ meta: { type: 'post' }, placeholder: i18n.__('Write a public message') })
5761 ]
5862
5963 var getStream = (opts) => {
6064 if (opts.lt != null && !opts.lt.marker) {
@@ -111,11 +115,11 @@
111115 })
112116 return [
113117 h('button -pub -full', {
114118 'ev-click': api.invite.sheet
115- }, '+ Join Pub'),
116- when(loading, [ h('Loading') ], [
117- when(computed(channels, x => x.length), h('h2', 'Active Channels')),
119+ }, i18n.__('+ Join Pub')),
120+ when(loading, [ h(i18n.__("Loading")) ], [
121+ when(computed(channels, x => x.length), h('h2', i18n.__("Active Channels"))),
118122 h('div', {
119123 classList: 'ChannelList',
120124 hidden: loading
121125 }, [
@@ -130,23 +134,23 @@
130134 h('span.name', '#' + channel),
131135 when(subscribed,
132136 h('a.-unsubscribe', {
133137 'ev-click': send(unsubscribe, channel)
134- }, 'Unsubscribe'),
138+ }, i18n.__('Unsubscribe')),
135139 h('a.-subscribe', {
136140 'ev-click': send(subscribe, channel)
137- }, 'Subscribe')
141+ }, i18n.__('Subscribe'))
138142 )
139143 ])
140144 }, {maxTime: 5}),
141- h('a.channel -more', {href: '/channels'}, 'More Channels...')
145+ h('a.channel -more', {href: '/channels'}, i18n.__('More Channels...'))
142146 ])
143147 ]),
144148
145- PeerList(localPeers, 'Local'),
146- PeerList(connectedPubs, 'Connected Pubs'),
149+ PeerList(localPeers, i18n.__('Local')),
150+ PeerList(connectedPubs, i18n.__('Connected Pubs')),
147151
148- when(computed(whoToFollow, x => x.length), h('h2', 'Who to follow')),
152+ when(computed(whoToFollow, x => x.length), h('h2', i18n.__('Who to follow'))),
149153 when(following.sync,
150154 h('div', {
151155 classList: 'ProfileList'
152156 }, [
package.jsonView
@@ -1,7 +1,7 @@
11 {
22 "name": "ssb-patchwork",
3- "productName": "Patchwork",
3+ "productName": "patchwork",
44 "repository": "git@github.com:ssbc/patchwork.git",
55 "version": "3.6.6",
66 "description": "A decentralized messaging and sharing app built on top of Secure Scuttlebutt (SSB).",
77 "main": "index.js",
@@ -13,8 +13,9 @@
1313 },
1414 "author": "Secure Scuttlebutt Consortium",
1515 "license": "AGPL-3.0",
1616 "dependencies": {
17+ "app-root-path": "^2.0.1",
1718 "bulk-require": "^1.0.0",
1819 "compare-version": "^0.1.2",
1920 "cross-script": "^1.0.1",
2021 "deep-equal": "^1.0.1",
@@ -26,8 +27,9 @@
2627 "fix-path": "^2.1.0",
2728 "flatpickr": "^3.0.5-1",
2829 "flumeview-level": "^2.0.3",
2930 "hashlru": "^2.2.0",
31+ "i18n": "^0.8.3",
3032 "insert-css": "~2.0.0",
3133 "level": "~1.7.0",
3234 "lrucache": "^1.0.2",
3335 "micro-css": "^2.0.1",
server-process.jsView
@@ -1,4 +1,6 @@
1+global.i18n = require('./lib/i18n').i18n
2+
13 var serveBlobs = require('./lib/serve-blobs')
24 var fs = require('fs')
35 var Path = require('path')
46 var electron = require('electron')
locales/en.jsonView
@@ -1,0 +1,13 @@
1+{
2+ "Patchwork": "Patchwork",
3+ "Public": "Public",
4+ "Private": "Private",
5+ "Write a public message": "Write a public message",
6+ "Active Channels": "Active Channels",
7+ "Loading": "Loading",
8+ "Local": "Local",
9+ "Connected Pubs": "Connected Pubs",
10+ "Who to follow": "Who to follow",
11+ "Unsubscribe": "Unsubscribe",
12+ "Subscribe": "Subscribe"
13+}
locales/ki.jsonView
@@ -1,0 +1,29 @@
1+{
2+ "Write a public message": "پبلک پیغام لکھنے",
3+ "Active Channels": "فعال",
4+ "Loading": "لوڈ ہو رہا ہے",
5+ "Local": "مقامی",
6+ "Connected Pubs": "مربوط عوامی مقامات",
7+ "Who to follow": "جو پیروی کرنے کے لئے",
8+ "Public": "عوام",
9+ "Private": "نجی",
10+ "Patchwork": "जन्द । नक्तकः",
11+ "Unsubscribe": "رکنیت ختم",
12+ "Subscribe": "سبسکرائب",
13+ "+ Join Pub": "+ عوامی جگہ شمولیت",
14+ "Profile": "تم",
15+ "Mentions": "تذکرے",
16+ "Show ": "شو ",
17+ "update": "اپ ڈیٹ",
18+ "updates": "اپ ڈیٹ",
19+ " liked this message": " اس پیغام کو پسند کیا",
20+ "View full thread": "مکمل دھاگے کو دیکھیں",
21+ " replied": " جواب",
22+ " subscribed to ": " سبسکرائب ",
23+ " replied to ": " کا جواب دیا ",
24+ " followed ": " کی پیروی کی ",
25+ " and ": " اور ",
26+ " others": " دوسروں",
27+ " liked ": " پسند کیا ",
28+ "word, @key, #channel": "word, @key, #channel"
29+}

Built with git-ssb-web