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
cef2bf0c
Commit
cef2bf0c
authored
Oct 18, 2018
by
Vladislav Lagunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Рефакторинг gettext
parent
e5927de2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
10 deletions
+12
-10
AutoComplete.tsx
+1
-1
Suggestions.tsx
+5
-5
TextField.tsx
+5
-4
i18n/index.ts
+1
-0
No files found.
AutoComplete.tsx
View file @
cef2bf0c
...
...
@@ -195,7 +195,7 @@ export default class AutoComplete<A=string> extends React.Component<Props<A>, St
{
!
observable
&&
(
children
?
React
.
cloneElement
(
children
,
this
.
childrenProps
())
:
<
TextField
{
...
this
.
childrenProps
()
as
any
}
{
...
textFieldProps
}
/>)
}
<
Suggestions
{
...
suggestionProps
}
ctx=
{
ctx
}
ctx=
{
ctx
!
}
anchorEl=
{
anchorEl
||
this
.
anchorEl
||
undefined
}
open=
{
open
}
suggestions=
{
suggestions
}
...
...
Suggestions.tsx
View file @
cef2bf0c
...
...
@@ -8,12 +8,13 @@ import Paper from '@material-ui/core/Paper';
import
withStyles
,
{
WithStyles
,
StyleRules
}
from
'@material-ui/core/styles/withStyles'
;
import
{
StandardProps
}
from
'@material-ui/core'
;
import
PendingOverlay
from
'@bitmaster/components/PendingOverlay'
;
import
{
Ctx
,
pgettext
}
from
'@bitmaster/utils
/gettext'
;
import
{
LocaleCtx
,
Gettext
,
withGettext
}
from
'~
/gettext'
;
// props
export
type
Props
<
A
=
any
>
=
StandardProps
<
React
.
HTMLProps
<
HTMLDivElement
>
,
string
>
&
WithStyles
<
string
>
&
{
ctx
?:
Ctx
;
__
:
Gettext
;
ctx
:
LocaleCtx
;
suggestions
:
A
[];
renderSuggestion
?(
a
:
A
):
React
.
ReactElement
<
MenuItemProps
>|
string
;
anchorEl
?:
HTMLElement
;
...
...
@@ -178,9 +179,8 @@ class Suggestions<A> extends React.Component<Props<A>, State> {
}
render()
{
const
{
classes
,
open
,
pending
,
suggestions
,
ctx
}
=
this
.
props
;
const
{
__
,
classes
,
open
,
pending
,
suggestions
}
=
this
.
props
;
const
PaperProps
=
{
ref
:
this
.
handlePaperRef
,
className
:
classes
.
paper
};
const
__
=
k
=>
pgettext
(
ctx
||
null
,
'autocomplete'
,
k
);
return
<
Modal
className=
{
classes
.
modal
}
open=
{
!!
open
}
onClose=
{
this
.
handleClose
}
disableAutoFocus
disableEnforceFocus
disableRestoreFocus
hideBackdrop
>
<
Paper
{
...
PaperProps
}
>
...
...
@@ -192,7 +192,7 @@ class Suggestions<A> extends React.Component<Props<A>, State> {
}
}
export default withStyles(styles)(
Suggestions
);
export default withStyles(styles)(
withGettext(require('./i18n'))(Suggestions)
);
// Styles
...
...
TextField.tsx
View file @
cef2bf0c
import
*
as
React
from
'react'
;
import
{
pgettext
}
from
'@bitmaster/utils/gettext'
;
import
{
Theme
}
from
'@material-ui/core/styles/createMuiTheme'
;
import
withStyles
,
{
StyleRules
,
WithStyles
}
from
'@material-ui/core/styles/withStyles'
;
import
*
as
classNames
from
'classnames'
;
import
{
FieldProps
}
from
'./'
;
import
{
StandardProps
}
from
'@material-ui/core'
;
import
{
withGettext
,
Gettext
,
LocaleCtx
}
from
'~/gettext'
;
const
eye
=
require
(
'./eye.svg'
);
const
eyeSlash
=
require
(
'./eye-slash.svg'
);
// Props
export
type
Props
=
StandardProps
<
React
.
HTMLProps
<
HTMLDivElement
>
,
ClassKey
,
'ref'
|
'onKeyDown'
|
'disabled'
>
&
FieldProps
<
string
>
&
WithStyles
<
ClassKey
>
&
{
__
:
Gettext
;
ctx
?:
LocaleCtx
;
type
?:
React
.
HTMLProps
<
HTMLInputElement
>
[
'type'
];
filter
?(
s
:
string
):
boolean
;
regexFilter
?:
RegExp
;
...
...
@@ -54,6 +55,7 @@ export class TextField extends React.Component<Props, State> {
render
()
{
const
{
__
,
ctx
,
classes
,
// dirty,
...
...
@@ -84,7 +86,6 @@ export class TextField extends React.Component<Props, State> {
const
inputClass
=
classNames
(
classes
.
input
,
{
[
classes
.
error
]:
error
,
});
const
__
=
k
=>
ctx
?
pgettext
(
ctx
,
'fields'
,
k
)
:
k
;
const
Input
:
any
=
InputProp
||
'input'
;
const
endAdornment
=
type
!==
'password-switch'
?
_endAdornment
:
<
React
.
Fragment
>
{
_endAdornment
}
...
...
@@ -112,7 +113,7 @@ export class TextField extends React.Component<Props, State> {
}
}
export
default
withStyles
(
styles
)(
TextField
);
export
default
withStyles
(
styles
)(
withGettext
(
require
(
'./i18n'
))(
TextField
)
);
// CSS классы
...
...
i18n/index.ts
View file @
cef2bf0c
export
default
{
"ru-RU"
:
{
"Fill out this field"
:
"Заполните это поле"
,
"Nothing found…"
:
"Ничего не найдено…"
,
},
"lt-LT"
:
{
},
...
...
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