Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
a8c77104
Commit
a8c77104
authored
Feb 09, 2019
by
Nick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: load dev locale files
parent
466c05f8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
3 deletions
+72
-3
CHANGELOG.md
CHANGELOG.md
+2
-1
admin-storage.vue
client/components/admin/admin-storage.vue
+1
-1
data.yml
server/app/data.yml
+2
-1
localization.js
server/core/localization.js
+47
-0
README.md
server/locales/README.md
+20
-0
No files found.
CHANGELOG.md
View file @
a8c77104
...
...
@@ -2,12 +2,13 @@
All notable changes to this project will be documented in this file.
This project adheres to
[
Semantic Versioning
](
http://semver.org/
)
.
## [2.0.0-beta.
12] - 2018-01-27
## [2.0.0-beta.
XX] - 2018-XX-XX
### Added
-
Added Patreon link in Contribute admin page
-
Added Theme Code Injection functionality
-
Added Theme CSS Injection code minification
-
Added Page Delete functionality
-
Dev locale .yml files in
`server/locales`
are now loaded
### Fixed
-
Fixed root admin refresh token fail
...
...
client/components/admin/admin-storage.vue
View file @
a8c77104
...
...
@@ -6,7 +6,7 @@
img(src='/svg/icon-cloud-storage.svg', alt='Storage', style='width: 80px;')
.admin-header-title
.headline.primary--text Storage
.subheading.grey--text Set backup and sync targets for your content
#[v-chip(label, color='primary', small).white--text coming soon]
.subheading.grey--text Set backup and sync targets for your content
v-spacer
v-btn(outline, color='grey', @click='refresh', large)
v-icon refresh
...
...
server/app/data.yml
View file @
a8c77104
...
...
@@ -7,7 +7,6 @@ defaults:
config
:
# File defaults
port
:
80
bindIP
:
0.0.0.0
db
:
type
:
postgres
host
:
localhost
...
...
@@ -23,6 +22,8 @@ defaults:
password
:
null
ssl
:
enabled
:
false
bindIP
:
0.0.0.0
logLevel
:
info
# DB defaults
graphEndpoint
:
'
https://graph.requarks.io'
lang
:
...
...
server/core/localization.js
View file @
a8c77104
...
...
@@ -3,6 +3,9 @@ const dotize = require('dotize')
const
i18nMW
=
require
(
'i18next-express-middleware'
)
const
i18next
=
require
(
'i18next'
)
const
Promise
=
require
(
'bluebird'
)
const
fs
=
require
(
'fs-extra'
)
const
path
=
require
(
'path'
)
const
yaml
=
require
(
'js-yaml'
)
/* global WIKI */
...
...
@@ -35,9 +38,20 @@ module.exports = {
return
this
},
/**
* Attach i18n middleware for Express
*
* @param {Object} app Express Instance
*/
attachMiddleware
(
app
)
{
app
.
use
(
i18nMW
.
handle
(
this
.
engine
))
},
/**
* Get all entries for a specific locale and namespace
*
* @param {String} locale Locale code
* @param {String} namespace Namespace
*/
async
getByNamespace
(
locale
,
namespace
)
{
if
(
this
.
engine
.
hasResourceBundle
(
locale
,
namespace
))
{
let
data
=
this
.
engine
.
getResourceBundle
(
locale
,
namespace
)
...
...
@@ -51,6 +65,12 @@ module.exports = {
throw
new
Error
(
'Invalid locale or namespace'
)
}
},
/**
* Load entries from the DB for a single locale
*
* @param {String} locale Locale code
* @param {*} opts Additional options
*/
async
loadLocale
(
locale
,
opts
=
{
silent
:
false
})
{
const
res
=
await
WIKI
.
models
.
locales
.
query
().
findOne
(
'code'
,
locale
)
if
(
res
)
{
...
...
@@ -63,7 +83,29 @@ module.exports = {
}
else
if
(
!
opts
.
silent
)
{
throw
new
Error
(
'No such locale in local store.'
)
}
//-> Load dev locale files if present
if
(
WIKI
.
IS_DEBUG
)
{
try
{
const
devEntriesRaw
=
await
fs
.
readFileAsync
(
path
.
join
(
WIKI
.
SERVERPATH
,
`locales/
${
locale
}
.yml`
),
'utf8'
)
if
(
devEntriesRaw
)
{
const
devEntries
=
yaml
.
safeLoad
(
devEntriesRaw
)
_
.
forOwn
(
devEntries
,
(
data
,
ns
)
=>
{
this
.
namespaces
.
push
(
ns
)
this
.
engine
.
addResourceBundle
(
locale
,
ns
,
data
,
true
,
true
)
})
WIKI
.
logger
.
info
(
`Loaded dev locales from
${
locale
}
.yml`
)
}
}
catch
(
err
)
{
// ignore
}
}
},
/**
* Reload all namespaces for all active locales from the DB
*
* @param {Boolean} silent No error on fail
*/
async
refreshNamespaces
(
silent
=
false
)
{
await
this
.
loadLocale
(
WIKI
.
config
.
lang
.
code
,
{
silent
})
if
(
WIKI
.
config
.
lang
.
namespacing
)
{
...
...
@@ -72,6 +114,11 @@ module.exports = {
}
}
},
/**
* Set the active locale
*
* @param {String} locale Locale code
*/
async
setCurrentLocale
(
locale
)
{
await
Promise
.
fromCallback
(
cb
=>
{
return
this
.
engine
.
changeLanguage
(
locale
,
cb
)
...
...
server/locales/README.md
0 → 100644
View file @
a8c77104
## IMPORTANT
Localization files are not stored into files!
Contact us on Gitter to request access to the translation web service: https://gitter.im/Requarks/wiki
## Development Mode
If you need to add new keys and test them live, simply create a {LANG}.yml file in this folder containing the values you want to test. e.g.:
### en.yml
```
yml
admin
:
api.title
:
'
API
Access'
auth.title
:
'
Authentication'
```
The official localization keys will still be loaded first, but your local files will overwrite any existing keys (and add new ones).
Note that you must restart Wiki.js to load any changes made to the files, which happens automatically on save when in dev mode.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment