Skip to content

Commit 34ee1ab

Browse files
authored
Feat/i18n (gramps-project#87)
* add new translations and fix existing * add index file to handle exporting all translations so we can import them as a single line in string.js * Added some plugins to handle json translation files. Rollup now converts them to javascript objects during application build * upgrade rollup to 2.60.2 to fix build issues * Add more translation strings
1 parent 53d3287 commit 34ee1ab

10 files changed

+402
-127
lines changed

package-lock.json

Lines changed: 231 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"start": "web-dev-server --app-index index.html --node-resolve --open --watch"
1616
},
1717
"devDependencies": {
18+
"@babel/plugin-syntax-import-assertions": "^7.18.6",
1819
"@open-wc/building-rollup": "^1.9.4",
1920
"@open-wc/demoing-storybook": "^2.4.6",
2021
"@open-wc/eslint-config": "^4.0.1",
@@ -34,7 +35,8 @@
3435
"lint-staged": "^10.5.3",
3536
"prettier": "^2.2.1",
3637
"rimraf": "^3.0.2",
37-
"rollup": "^2.35.1"
38+
"rollup": "^2.60.2",
39+
"rollup-plugin-import-assertions": "^0.3.0"
3840
},
3941
"browser": {
4042
"crypto": false
@@ -61,6 +63,11 @@
6163
"git add"
6264
]
6365
},
66+
"babel": {
67+
"plugins": [
68+
"@babel/plugin-syntax-import-assertions"
69+
]
70+
},
6471
"name": "gramps-js",
6572
"version": "0.13.3",
6673
"description": "Single-page app serving as frontend to the Gramps genealogical research system.",

rollup.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import merge from 'deepmerge'
22
import copy from 'rollup-plugin-copy'
33
import {createSpaConfig} from '@open-wc/building-rollup'
4+
import importAssertions from 'rollup-plugin-import-assertions'
45
import replace from '@rollup/plugin-replace'
56

67
const API_URL = (process.env.API_URL === undefined)
@@ -56,6 +57,7 @@ export default merge(baseConfig, {
5657
'http://localhost:5555': API_URL,
5758
BASE_DIR: JSON.stringify(BASE_DIR),
5859
preventAssignment: true
59-
})
60+
}),
61+
importAssertions()
6062
]
6163
})

src/components/GrampsjsFirstRun.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ class GrampsjsFirstRun extends GrampsjsTranslateMixin(LitElement) {
128128
return html`
129129
<div class="container">
130130
<div class="form">
131-
<h1>Welcome to Gramps Web</h1>
131+
<h1>${this._('Welcome to Gramps Web')}</h1>
132132
133-
<h3>Create an admin account
133+
<h3>${this._('Create an admin account')}
134134
${this.stateUser !== STATE_INITIAL
135135
? html`
136136
<span class="icon">
@@ -140,7 +140,7 @@ class GrampsjsFirstRun extends GrampsjsTranslateMixin(LitElement) {
140140
: ''}
141141
</h3>
142142
143-
<p>Enter the details for the admin user.</p>
143+
<p>${this._('Enter the details for the admin user.')}</p>
144144
145145
<mwc-textfield @input="${this.checkValidity}" outlined required id="username" label="Username" type="text"></mwc-textfield>
146146
<mwc-textfield @input="${this.checkValidity}" outlined required id="password" label="Password" type="password"></mwc-textfield>
@@ -157,16 +157,16 @@ class GrampsjsFirstRun extends GrampsjsTranslateMixin(LitElement) {
157157
: ''}
158158
</h3>
159159
160-
<p>Optionally, enter existing IMAP credentials to enable e-mail notifications required e.g. for user registration.</p>
160+
<p>${this._('Optionally, enter existing IMAP credentials to enable e-mail notifications required e.g. for user registration.')}</p>
161161
162-
<mwc-textfield @input="${this.checkValidity}" outlined id="email_host" label="SMTP host" type="text"></mwc-textfield>
163-
<mwc-textfield @input="${this.checkValidity}" outlined id="email_port" label="SMTP port" type="text" pattern="[0-9]+"></mwc-textfield>
164-
<mwc-textfield @input="${this.checkValidity}" outlined id="email_user" label="SMTP user" type="text"></mwc-textfield>
165-
<mwc-textfield @input="${this.checkValidity}" outlined id="email_pw" label="SMTP password" type="password"></mwc-textfield>
166-
<mwc-textfield @input="${this.checkValidity}" outlined id="email_from" label="From address" type="email"></mwc-textfield>
167-
<mwc-textfield @input="${this.checkValidity}" outlined id="base_url" label="Gramps Web base URL" type="url" placeholder="https://grampsweb.mydomain.com"></mwc-textfield>
162+
<mwc-textfield @input="${this.checkValidity}" outlined id="email_host" label="${this._('SMTP host')}" type="text"></mwc-textfield>
163+
<mwc-textfield @input="${this.checkValidity}" outlined id="email_port" label="${this._('SMTP port')}" type="text" pattern="[0-9]+"></mwc-textfield>
164+
<mwc-textfield @input="${this.checkValidity}" outlined id="email_user" label="${this._('SMTP user')}" type="text"></mwc-textfield>
165+
<mwc-textfield @input="${this.checkValidity}" outlined id="email_pw" label="${this._('SMTP password')}" type="password"></mwc-textfield>
166+
<mwc-textfield @input="${this.checkValidity}" outlined id="email_from" label="${this._('From address')}" type="email"></mwc-textfield>
167+
<mwc-textfield @input="${this.checkValidity}" outlined id="base_url" label="${this._('Gramps Web base URL')}" type="url" placeholder="https://grampsweb.mydomain.com"></mwc-textfield>
168168
169-
<h3>Upload family tree
169+
<h3>${this._('Upload family tree')}
170170
${this.stateTree !== STATE_INITIAL
171171
? html`
172172
<span class="icon">
@@ -176,7 +176,7 @@ class GrampsjsFirstRun extends GrampsjsTranslateMixin(LitElement) {
176176
: ''}
177177
</h3>
178178
179-
<p>Optionally, upload existing family tree data.</p>
179+
<p>${this._('Optionally, upload existing family tree data.')}</p>
180180
181181
<p>
182182
<grampsjs-form-upload
@@ -187,9 +187,9 @@ class GrampsjsFirstRun extends GrampsjsTranslateMixin(LitElement) {
187187
</p>
188188
${this._uploadHint ? html`${this._uploadHint}` : ''}
189189
190-
<p style="margin-top: 2em;">Need help? Check out <a href="https://gramps-project.github.io/web/Deployment/">the documentation</a>.</p>
190+
<p style="margin-top: 2em;">${this._('Need help? Check out ')}<a href="https://gramps-project.github.io/web/Deployment/">${this._('the documentation')}</a>.</p>
191191
192-
<h3>Submit</h3>
192+
<h3>${this._('Submit')}</h3>
193193
194194
<mwc-button
195195
raised
@@ -286,7 +286,7 @@ class GrampsjsFirstRun extends GrampsjsTranslateMixin(LitElement) {
286286
try {
287287
const resp = await fetch(`${__APIHOST__}/api/users/${username}/create_owner/`, {
288288
method: 'POST',
289-
headers: {Accept: 'application/json', Authorization: `Bearer ${this.token}`, 'Content-Type': 'application/json'},
289+
headers: { Accept: 'application/json', Authorization: `Bearer ${this.token}`, 'Content-Type': 'application/json' },
290290
body: JSON.stringify({
291291
password: password,
292292
email: email,
@@ -297,7 +297,7 @@ class GrampsjsFirstRun extends GrampsjsTranslateMixin(LitElement) {
297297
this.stateUser = STATE_DONE
298298
const btn = this.shadowRoot.querySelector('#start-btn')
299299
if (btn) {
300-
btn.scrollIntoView({block: 'start', behavior: 'smooth'})
300+
btn.scrollIntoView({ block: 'start', behavior: 'smooth' })
301301
}
302302
return
303303
} else {
@@ -359,18 +359,17 @@ class GrampsjsFirstRun extends GrampsjsTranslateMixin(LitElement) {
359359

360360
const ext = uploadForm.file.name.split('.').pop().toLowerCase()
361361
if (!['gpkg', 'gramps', 'gw', 'def', 'vcf', 'csv', 'ged'].includes(ext)) {
362-
this._uploadHint = html`<p class="alert error">Unsupported format</p>`
362+
this._uploadHint = html`<p class="alert error">${this._('Unsupported format')}</p>`
363363
this.stateTree = STATE_INITIAL
364364
return
365365
}
366366
if (ext === 'gpkg') {
367-
this._uploadHint = html`<p class="alert error">The Gramps package format (.gpkg) is currently not supported.
368-
Please upload a file in Gramps XML (.gramps) format without media files.</p>`
367+
this._uploadHint = html`<p class="alert error">${this._('The Gramps package format (.gpkg) is currently not supported.')}
368+
${this._('Please upload a file in Gramps XML (.gramps) format without media files.')}</p>`
369369
this.stateTree = STATE_INITIAL
370370
return
371371
} else if (ext !== 'gramps') {
372-
this._uploadHint = html`<p class="alert warn">If you intend to synchronize an existing Gramps database with Gramps Web,
373-
use the Gramps XML (.gramps) format instead.</p>`
372+
this._uploadHint = html`<p class="alert warn">${this._('If you intend to synchronize an existing Gramps database with Gramps Web, use the Gramps XML (.gramps) format instead.')}</p>`
374373
} else {
375374
this._uploadHint = ''
376375
}

src/lang/de.json

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,39 @@
1616
"Recently changed objects": "Kürzlich geänderte Objekte",
1717
"Select language": "Sprache auswählen",
1818
"Show in tree": "Im Stammbaum anzeigen",
19-
"User settings": "Benutzer-Einstellungen"
19+
"User settings": "Benutzer-Einstellungen",
20+
"Anniversaries": "Jahrestage",
21+
"Export": "Exportieren",
22+
"Search": "Suche",
23+
"Navigation": "Navigation",
24+
"Global": "Global",
25+
"Edit coordinates": "Koordinaten bearbeiten",
26+
"Search %s": "%s durchsuchen",
27+
"Latest Blog Post": "Neuester Blogeintrag",
28+
"Align the image": "Bild ausrichten",
29+
"Select a point on the map": "Einen Punkt auf der Karte wählen",
30+
"Select an existing citation": "Eine existierende Fundstelle auswählen",
31+
"Place Hierarchy": "Ortshierarchie",
32+
"Keyboard Shortcuts": "Tastenkombinationen",
33+
"Show this dialog": "Diesen Dialog anzeigen",
34+
"To start using the blog, add a source with tag 'Blog'.": "Um das Blog zu starten, muss eine Quelle mit dem Tag 'Blog' hinzugefügt werden.",
35+
"Welcome to Gramps Web": "Willkommen auf Gramps Web",
36+
"Create an admin account": "Ein Administratorkonto erstellen",
37+
"Enter the details for the admin user.": "Die Details für den Admin-Benutzer eingeben.",
38+
"Optionally, enter existing IMAP credentials to enable e-mail notifications required e.g. for user registration.": "Optional müssen vorhandene IMAP-Zugangsdaten eingegeben werden, um E-Mail-Benachrichtigungen zu aktivieren, die z. B. für die Benutzerregistrierung erforderlich sind.",
39+
"SMTP host": "SMTP-Host",
40+
"SMTP port": "SMTP-Port",
41+
"SMTP user": "SMTP-Benutzer",
42+
"SMTP password": "SMTP-Kennwort",
43+
"From address": "Adresse von",
44+
"Gramps Web base URL": "Gramps Web-Basis-URL",
45+
"Upload family tree": "Stammbaum hochladen",
46+
"Optionally, upload existing family tree data.": "Optional besteht die Möglichkeit, vorhandene Stammbaumdaten hochzuladen.",
47+
"Need help? Check out ": "Hilfe benötigt? Siehe unter ",
48+
"the documentation": "die Dokumentation",
49+
"Submit": "Senden",
50+
"Unsupported format": "Nicht unterstütztes Format",
51+
"The Gramps package format (.gpkg) is currently not supported.": "Das Gramps-Paketformat (.gpkg) wird derzeit nicht unterstützt.",
52+
"Please upload a file in Gramps XML (.gramps) format without media files.": "Bitte eine Datei im Gramps XML (.gramps) Format ohne Mediendateien hochladen.",
53+
"If you intend to synchronize an existing Gramps database with Gramps Web, use the Gramps XML (.gramps) format instead.": "Wenn Sie eine bestehende Gramps-Datenbank mit Gramps Web synchronisieren möchten, verwenden Sie stattdessen das Gramps-XML-Format (.gramps)."
2054
}

src/lang/en_GB.json

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,39 @@
1616
"Recently changed objects": "Recently changed objects",
1717
"Select language": "Select language",
1818
"Show in tree": "Show in tree",
19-
"User settings": "User settings"
19+
"User settings": "User settings",
20+
"Anniversaries": "Anniversaries",
21+
"Export": "Export",
22+
"Search": "Search",
23+
"Navigation": "Navigation",
24+
"Global": "Global",
25+
"Edit coordinates": "Edit coordinates",
26+
"Search %s": "Search %s",
27+
"Latest Blog Post": "Latest Blog Post",
28+
"Align the image": "Align the image",
29+
"Select a point on the map": "Select a point on the map",
30+
"Select an existing citation": "Select an existing citation",
31+
"Place Hierarchy": "Place Hierarchy",
32+
"Keyboard Shortcuts": "Keyboard Shortcuts",
33+
"Show this dialog": "Show this dialog",
34+
"To start using the blog, add a source with tag 'Blog'.": "To start using the blog, add a source with tag 'Blog'.",
35+
"Welcome to Gramps Web": "Welcome to Gramps Web",
36+
"Create an admin account": "Create an admin account",
37+
"Enter the details for the admin user.": "Enter the details for the admin user.",
38+
"Optionally, enter existing IMAP credentials to enable e-mail notifications required e.g. for user registration.": "Optionally, enter existing IMAP credentials to enable e-mail notifications required e.g. for user registration.",
39+
"SMTP host": "SMTP host",
40+
"SMTP port": "SMTP port",
41+
"SMTP user": "SMTP user",
42+
"SMTP password": "SMTP password",
43+
"From address": "From address",
44+
"Gramps Web base URL": "Gramps Web base URL",
45+
"Upload family tree": "Upload family tree",
46+
"Optionally, upload existing family tree data.": "Optionally, upload existing family tree data.",
47+
"Need help? Check out ": "Need help? Check out ",
48+
"the documentation": "the documentation",
49+
"Submit": "Submit",
50+
"Unsupported format": "Unsupported format",
51+
"The Gramps package format (.gpkg) is currently not supported.": "The Gramps package format (.gpkg) is currently not supported.",
52+
"Please upload a file in Gramps XML (.gramps) format without media files.": "Please upload a file in Gramps XML (.gramps) format without media files.",
53+
"If you intend to synchronize an existing Gramps database with Gramps Web, use the Gramps XML (.gramps) format instead.": "If you intend to synchronize an existing Gramps database with Gramps Web, use the Gramps XML (.gramps) format instead."
2054
}

src/lang/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import en from './en_GB.json' assert {type: 'json'}
2+
import ru from './ru.json' assert {type: 'json'}
3+
import de from './de.json' assert {type: 'json'}
4+
5+
const languages = {
6+
en: en,
7+
ru: ru,
8+
de: de
9+
}
10+
11+
const translations = languages
12+
13+
export default translations

src/lang/ru.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"A new version of the app is available.": "Доступна новая версия приложения.",
3+
"Blog": "Блог",
4+
"Change E-mail": "Изменить электронную почту",
5+
"Change password": "Изменить пароль",
6+
"Discard": "Отказаться",
7+
"History": "История",
8+
"Home Person": "Главный человек",
9+
"Lists": "Списки",
10+
"Manage users": "Управление пользователями",
11+
"Menu": "Меню",
12+
"New E-mail": "Новая электронная почта",
13+
"New password": "Новый пароль",
14+
"Old password": "Старый пароль",
15+
"Recently browsed objects": "Недавно просмотренные объекты",
16+
"Recently changed objects": "Недавно измененные объекты",
17+
"Select language": "Выберите язык",
18+
"Show in tree": "Показать в дереве",
19+
"User settings": "Настройки пользователя",
20+
"Anniversaries": "Юбилеи",
21+
"Export": "Экспортировать",
22+
"Search": "Искать",
23+
"Navigation": "Навигация",
24+
"Global": "Глобальный",
25+
"Edit coordinates": "Редактировать координаты",
26+
"Search %s": "Искать %s",
27+
"Latest Blog Post": "Последние записи в блоге",
28+
"Align the image": "Выравнивание изображения",
29+
"Select a point on the map": "Выберите точку на карте",
30+
"Select an existing citation": "Выберите существующую цитату",
31+
"Place Hierarchy": "Иерархия мест",
32+
"Keyboard Shortcuts": "Клавиатурные сокращения",
33+
"Show this dialog": "Показать это диалоговое окно",
34+
"To start using the blog, add a source with tag 'Blog'.": "Чтобы начать использовать блог, добавьте источник с тегом 'Blog'.",
35+
"Welcome to Gramps Web": "Добро пожаловать в Gramps Web",
36+
"Create an admin account": "Создайте учетную запись администратора",
37+
"Enter the details for the admin user.": "Введите данные для пользователя-администратора.",
38+
"Optionally, enter existing IMAP credentials to enable e-mail notifications required e.g. for user registration.": "По желанию введите существующие учетные данные IMAP, чтобы включить уведомления по электронной почте, необходимые, например, для регистрации пользователя.",
39+
"SMTP host": "SMTP-хост",
40+
"SMTP port": "SMTP-порт",
41+
"SMTP user": "SMTP-пользователь",
42+
"SMTP password": "SMTP-пароль",
43+
"From address": "С адреса",
44+
"Gramps Web base URL": "Gramps Web базовый URL",
45+
"Upload family tree": "Загрузить семейное дерево",
46+
"Optionally, upload existing family tree data.": "По желанию, загрузите существующие данные семейного древа.",
47+
"Need help? Check out ": "Нужна помощь? Посмотрите ",
48+
"the documentation": "документацию",
49+
"Submit": "Отправить",
50+
"Unsupported format": "Неподдерживаемый формат",
51+
"The Gramps package format (.gpkg) is currently not supported.": "Формат пакета Gramps (.gpkg) в настоящее время не поддерживается.",
52+
"Please upload a file in Gramps XML (.gramps) format without media files.": "Пожалуйста, загрузите файл в формате Gramps XML (.gramps) без медиафайлов.",
53+
"If you intend to synchronize an existing Gramps database with Gramps Web, use the Gramps XML (.gramps) format instead.": "Если вы собираетесь синхронизировать существующую базу данных Gramps с Gramps Web, используйте формат Gramps XML (.gramps)."
54+
}

src/strings.js

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,9 @@
1+
import translations from './lang/index.js'
12
/*
23
All strings that need to be translated
34
*/
45

5-
export const additionalStrings = {
6-
de: {
7-
Anniversaries: 'Jahrestage',
8-
Discard: 'Verwerfen',
9-
Lists: 'Listen',
10-
History: 'Verlauf',
11-
Menu: 'Menü',
12-
Blog: 'Blog',
13-
Export: 'Exportieren',
14-
Search: 'Suche',
15-
Navigation: 'Navigation',
16-
Global: 'Global',
17-
'Edit coordinates': 'Koordinaten bearbeiten',
18-
'Recently browsed objects': 'Kürzlich betrachtete Objekte',
19-
'Recently changed objects': 'Kürzlich geänderte Objekte',
20-
'Show in tree': 'Im Stammbaum anzeigen',
21-
'User settings': 'Benutzer-Einstellungen',
22-
'Select language': 'Sprache auswählen',
23-
'Home Person': 'Hauptperson',
24-
'Change E-mail': 'E-Mail-Adresse ändern',
25-
'Change password': 'Passwort ändern',
26-
'Old password': 'Altes Passwort',
27-
'New password': 'Neues Passwort',
28-
'New E-mail': 'Neue E-Mail-Adresse',
29-
'A new version of the app is available.': 'Eine neue Version der App ist verfügbar.',
30-
'Manage users': 'Benutzer verwalten',
31-
'Search %s': '%s durchsuchen',
32-
'Latest Blog Post': 'Neuester Blogeintrag',
33-
'Align the image': 'Bild ausrichten',
34-
'Select a point on the map': 'Einen Punkt auf der Karte wählen',
35-
'Select an existing citation': 'Eine existierende Fundstelle auswählen',
36-
'Place Hierarchy': 'Ortshierarchie',
37-
'Keyboard Shortcuts': 'Tastenkombinationen',
38-
'Show this dialog': 'Diesen Dialog anzeigen'
39-
}
40-
}
6+
export const additionalStrings = translations
417

428
export const grampsStrings = [
439
'_Media Type:',

src/views/GrampsjsViewBlog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class GrampsjsViewBlog extends GrampsjsView {
5050
if (this._firstLoaded && this._dataSources.length === 0) {
5151
return html`
5252
<h2>${this._('Blog')}</h2>
53-
<p class="muted">To start using the blog, add a source with tag 'Blog'.</p>
53+
<p class="muted">${this._("To start using the blog, add a source with tag 'Blog'.")}</p>
5454
`
5555
}
5656
if (this.loading) {

0 commit comments

Comments
 (0)