1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-30 10:36:35 +02:00

Server: Improved string localization in views

This commit is contained in:
Laurent Cozic 2022-01-11 15:11:37 +00:00
parent 09cbe3cb7c
commit 98bfb65ead
2 changed files with 15 additions and 13 deletions

View File

@ -27,6 +27,7 @@ export interface View {
partials?: string[];
cssFiles?: string[];
jsFiles?: string[];
strings?: Record<string, string>; // List of translatable strings
}
interface GlobalParams {
@ -46,6 +47,7 @@ interface GlobalParams {
isJoplinCloud?: boolean;
impersonatorAdminSessionId?: string;
csrfTag?: string;
s?: Record<string, string>; // List of translatable strings
}
export function isView(o: any): boolean {
@ -186,12 +188,6 @@ export default class MustacheService {
...this.defaultLayoutOptions,
...globalParams,
userDisplayName: this.userDisplayName(globalParams ? globalParams.owner : null),
};
const contentHtml = await this.renderFileContent(filePath, view, globalParams);
const layoutView: any = {
global: globalParams,
s: {
home: _('Home'),
users: _('Users'),
@ -201,6 +197,12 @@ export default class MustacheService {
help: _('Help'),
logout: _('Logout'),
},
};
const contentHtml = await this.renderFileContent(filePath, view, globalParams);
const layoutView: any = {
global: globalParams,
pageName: view.name,
pageTitle: view.titleOverride ? view.title : `${config().appName} - ${view.title}`,
contentHtml: contentHtml,

View File

@ -10,27 +10,27 @@
{{#global.owner}}
<div class="navbar-menu is-active">
<div class="navbar-start">
<a class="navbar-item" href="{{{global.baseUrl}}}/home">{{s.home}}</a>
<a class="navbar-item" href="{{{global.baseUrl}}}/home">{{global.s.home}}</a>
{{#global.owner.is_admin}}
<a class="navbar-item" href="{{{global.baseUrl}}}/users">{{s.users}}</a>
<a class="navbar-item" href="{{{global.baseUrl}}}/users">{{global.s.users}}</a>
{{/global.owner.is_admin}}
{{#global.owner.is_admin}}
<a class="navbar-item" href="{{{global.baseUrl}}}/items">{{s.items}}</a>
<a class="navbar-item" href="{{{global.baseUrl}}}/items">{{global.s.items}}</a>
{{/global.owner.is_admin}}
{{#global.owner.is_admin}}
<a class="navbar-item" href="{{{global.baseUrl}}}/changes">{{s.log}}</a>
<a class="navbar-item" href="{{{global.baseUrl}}}/changes">{{global.s.log}}</a>
{{/global.owner.is_admin}}
{{#global.owner.is_admin}}
<a class="navbar-item" href="{{{global.baseUrl}}}/tasks">{{s.tasks}}</a>
<a class="navbar-item" href="{{{global.baseUrl}}}/tasks">{{global.s.tasks}}</a>
{{/global.owner.is_admin}}
</div>
<div class="navbar-end">
{{#global.isJoplinCloud}}
<a class="navbar-item" href="{{{global.baseUrl}}}/help">{{s.help}}</a>
<a class="navbar-item" href="{{{global.baseUrl}}}/help">{{global.s.help}}</a>
{{/global.isJoplinCloud}}
<div class="navbar-item">
<form method="post" action="{{{global.baseUrl}}}/logout">
<button class="button is-dark">{{s.logout}}</button>
<button class="button is-dark">{{global.s.logout}}</button>
</form>
</div>
<div class="navbar-item">