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
bed3b650
Commit
bed3b650
authored
Feb 11, 2019
by
Andrey Golubov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Правка путей и eff
parent
d76b1caf
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
10 deletions
+17
-10
application/locale/index.ts
+11
-6
application/routes/index.ts
+4
-2
eff/index.ts
+2
-2
No files found.
application/locale/index.ts
View file @
bed3b650
import
*
as
eff
from
'~/common/eff
'
;
import
{
Ctx
as
TranslationCtx
,
Translations
}
from
'~/common/gettext
'
;
import
{
C
ache
as
LocalStorage
}
from
'~/common/persisten
t'
;
import
*
as
bcp47
from
'~/common/utils/bcp47
'
;
import
{
defaultLocale
,
localeCacheKey
,
localeDecoder
,
localePath
,
locales
}
from
'~/config
'
;
import
{
defaultLocale
,
localeCacheKey
,
localeDecoder
,
locales
}
from
'../../../config
'
;
import
*
as
eff
from
'../../eff
'
;
import
{
C
tx
as
TranslationCtx
,
Translations
}
from
'../../gettex
t'
;
import
{
Cache
as
LocalStorage
}
from
'../../persistent
'
;
import
*
as
bcp47
from
'../../utils/bcp47
'
;
import
{
Async
,
LocalStorageError
,
TranslationLoadError
}
from
'../error'
;
export
const
defaultTranslations
:
Translations
=
{
"locale_data"
:
{
"messages"
:
{
""
:
{
"domain"
:
"messages"
,
"lang"
:
"en"
,
"plural_forms"
:
"nplurals=2; plural=(n != 1);"
}
}
},
"domain"
:
"messages"
,
"debug"
:
false
}
export
type
Locale
=
typeof
localeDecoder
[
'_A'
];
export
type
Locales
=
Locale
[];
...
...
@@ -14,8 +15,12 @@ export const cache = new LocalStorage<Locale>(localeCacheKey, localeDecoder);
* @param locale вариант перевода из `Locales`
*/
export
function
loadTranslations
(
locale
:
Locale
):
Async
<
Translations
>
{
const
translations
:
Translations
|
undefined
=
require
(
`
${
localePath
(
'~'
)}${
locale
}
.po`
);
try
{
const
translations
:
Translations
|
undefined
=
require
(
`../../../i18n/
${
locale
}
.po`
);
return
translations
?
eff
.
success
(
translations
)
:
eff
.
failure
(
TranslationLoadError
(
locale
));
}
catch
(
e
)
{
return
eff
.
of
(
defaultTranslations
);
}
}
/**
* Возвращает подходящую локаль из `window.navigator.languages` или `defaultLocale`
...
...
application/routes/index.ts
View file @
bed3b650
import
*
as
Rx
from
'rxjs'
;
import
{
defaultRoute
,
parser
}
from
'
~
/config'
;
import
{
defaultRoute
,
parser
}
from
'
../../..
/config'
;
import
*
as
eff
from
'../../eff'
;
import
{
IO
}
from
'../../types'
;
...
...
@@ -28,7 +28,9 @@ export function print(route: RouteIn): string {
*/
export
const
routeStream
=
new
Rx
.
Subject
<
RouteOut
[]
>
();
window
.
onpopstate
=
(()
=>
{
routeStream
.
next
(
parseLocation
(
window
.
location
));
});
try
{
window
.
onpopstate
=
(()
=>
{
routeStream
.
next
(
parseLocation
(
window
.
location
));
});
}
catch
(
e
)
{
console
.
warn
(
'Run in node'
);
}
export
function
routePush
(
route
:
RouteIn
,
title
:
string
=
''
):
IO
<
void
>
{
window
.
history
.
pushState
(
null
,
title
,
print
(
route
));
...
...
eff/index.ts
View file @
bed3b650
...
...
@@ -177,7 +177,7 @@ export function batch<A,B,C,D,E,F,G,H,I,J>(a: Cmd<A>, b: Cmd<B>, c: Cmd<C>, d: C
export
function
batch
<
array
extends
Cmd
<
any
>
[]
>
(
signals
:
array
):
Cmd
<
array
[
number
][
'_T'
][
'_R'
]
>
;
export
function
batch
():
Cmd
<
any
>
{
const
observables
=
Array
.
isArray
(
arguments
[
0
])
?
arguments
[
0
]
:
arguments
;
return
Rx
.
merge
.
apply
(
undefined
,
observables
);
return
Rx
.
merge
.
apply
(
undefined
,
observables
)
as
any
;
}
...
...
@@ -197,7 +197,7 @@ export function concat<A,B,C,D,E,F,G,H,I,J>(a: Cmd<A>, b: Cmd<B>, c: Cmd<C>, d:
export
function
concat
<
array
extends
Cmd
<
any
>
[]
>
(
signals
:
array
):
Cmd
<
array
[
number
][
'_T'
][
'_R'
]
>
;
export
function
concat
():
Cmd
<
any
>
{
const
observables
=
Array
.
isArray
(
arguments
[
0
])
?
arguments
[
0
]
:
arguments
;
return
Rx
.
concat
.
apply
(
undefined
,
observables
);
return
Rx
.
concat
.
apply
(
undefined
,
observables
)
as
any
;
}
...
...
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