Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
npm
common
Commits
c7b12244
Commit
c7b12244
authored
Oct 31, 2018
by
Vladislav Lagunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Поддержка *.po формата
parent
74013b7d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
gettext/README.md
+3
-1
gettext/index.ts
+11
-4
No files found.
gettext/README.md
View file @
c7b12244
...
@@ -40,7 +40,9 @@ export default withGettext(gettext)(Widget);
...
@@ -40,7 +40,9 @@ export default withGettext(gettext)(Widget);
```
```
## Формат *.po.yml
## Формат *.po.yml
> 2018-10-31 DEPRECATED: Решил использовать стантартный формат *.po
Альтернативный формат, для
*
.po файлов предназначен предназначен для
Альтернативный формат, для
*
.po файлов предназначен предназначен для
более простой манипуляции с gettext-данными, и для обеспечения
более простой манипуляции с gettext-данными, и для обеспечения
...
...
gettext/index.ts
View file @
c7b12244
...
@@ -58,6 +58,7 @@ export function makeGettext(...webpackContexts): DeferredGettext {
...
@@ -58,6 +58,7 @@ export function makeGettext(...webpackContexts): DeferredGettext {
function
flattenModules
(
xs
:
any
[])
{
function
flattenModules
(
xs
:
any
[])
{
return
Array
.
prototype
.
concat
.
apply
([],
xs
.
map
(
x
=>
{
return
Array
.
prototype
.
concat
.
apply
([],
xs
.
map
(
x
=>
{
if
(
'__esModule'
in
x
)
x
=
x
.
default
;
return
Array
.
isArray
(
x
)
?
flattenModules
(
x
)
:
[
x
]
return
Array
.
isArray
(
x
)
?
flattenModules
(
x
)
:
[
x
]
}));
}));
}
}
...
@@ -120,15 +121,21 @@ export function requireTranslations(webpackContext /*: WebpackContext*/): Transl
...
@@ -120,15 +121,21 @@ export function requireTranslations(webpackContext /*: WebpackContext*/): Transl
*/
*/
function
assignData
(
dst
:
Translations
,
...
srcs
:
GettextData
[]):
Translations
{
function
assignData
(
dst
:
Translations
,
...
srcs
:
GettextData
[]):
Translations
{
srcs
.
forEach
(
data
=>
{
srcs
.
forEach
(
data
=>
{
const
locale
=
data
[
''
].
locale
;
if
(
!
locale
||
typeof
(
locale
)
!==
'string'
)
return
;
const
locale_
=
data
[
''
].
language
||
data
[
''
].
locale
;
if
(
!
locale_
||
typeof
(
locale_
)
!==
'string'
)
return
;
const
explicitKeys
=
data
[
'%podata'
];
const
locale
=
locale_
.
replace
(
/_/g
,
'-'
);
const
podata
=
data
[
'%podata'
];
for
(
const
k
of
Object
.
keys
(
data
))
{
for
(
const
k
of
Object
.
keys
(
data
))
{
if
(
k
===
''
||
k
===
'%podata'
)
continue
;
if
(
k
===
''
||
k
===
'%podata'
)
continue
;
dst
[
locale
]
=
dst
[
locale
]
||
{};
dst
[
locale
]
=
dst
[
locale
]
||
{};
dst
[
locale
][
k
]
=
data
[
k
];
if
(
Array
.
isArray
(
data
[
k
])
&&
data
[
k
][
0
]
===
null
)
{
dst
[
locale
][
k
]
=
data
[
k
].
slice
(
1
);
if
(
dst
[
locale
][
k
].
length
===
1
)
dst
[
locale
][
k
]
=
dst
[
locale
][
k
][
0
];
}
else
{
dst
[
locale
][
k
]
=
data
[
k
];
}
}
}
if
(
explicitKeys
)
for
(
const
explicit
of
explicitKeys
)
{
if
(
podata
)
for
(
const
explicit
of
podata
)
{
const
key
=
explicit
.
msgctxt
?
explicit
.
msgctxt
+
CONTEXT_DELIMITER
+
explicit
.
msgid
:
explicit
.
msgid
;
const
key
=
explicit
.
msgctxt
?
explicit
.
msgctxt
+
CONTEXT_DELIMITER
+
explicit
.
msgid
:
explicit
.
msgid
;
dst
[
locale
]
=
dst
[
locale
]
||
{};
dst
[
locale
]
=
dst
[
locale
]
||
{};
dst
[
locale
][
key
]
=
explicit
.
msgstr
;
dst
[
locale
][
key
]
=
explicit
.
msgstr
;
...
...
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