Skip to content

Commit 6a423a0

Browse files
committed
Move default language to its own file
1 parent 9147869 commit 6a423a0

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Returns:
163163
| `icons` | object | An object containing the mappings for the various icons and their components. See **Changing the Default Icons**. | `{ ... }` |
164164
| `iconsClass` | string | A string that specifies which icons class to utilize. Currently, `'fa4'` and `'fa5'` are supported. | `'fa5'` |
165165
| `id` | string | A string to be used for the HTML ID of the rendered tree and its nodes. | `null` |
166-
| `lang` | object | An object containing the language mappings for the various text elements. | `{ ... }` |
166+
| `lang` | object | A key-value pairing of localized text. See [`src/js/lang/default.js`][lang-file] for a list of keys. | `{ ... }` |
167167
| `name` | string | Optional name for the hidden `<input>` element. | `undefined` |
168168
| `nameAsArray` | bool | If true, the hidden `<input>` will encode its values as an array rather than a joined string. | `false` |
169169
| `nativeCheckboxes` | bool | If true, native browser checkboxes will be used instead of pseudo-checkbox icons. | `false` |
@@ -197,5 +197,6 @@ Individual nodes within the `nodes` property can have the following structure:
197197
[docs-controlled]: https://facebook.github.io/react/docs/forms.html#controlled-components
198198
[docs-state-hooks]: https://reactjs.org/docs/hooks-state.html
199199
[font-awesome]: https://fontawesome.com
200+
[lang-file]: https://github.com/jakezatecky/react-dual-listbox/blob/master/src/js/lang/default.js
200201
[mdn-key]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
201202
[react-fontawesome]: https://github.com/FortAwesome/react-fontawesome

src/js/CheckboxTree.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import PropTypes from 'prop-types';
66
import React from 'react';
77

88
import Button from './Button';
9-
import { CHECK_MODEL, KEYS } from './constants';
109
import NodeModel from './NodeModel';
1110
import TreeNode from './TreeNode';
11+
import defaultLang from './lang/default';
1212
import iconsShape from './shapes/iconsShape';
1313
import languageShape from './shapes/languageShape';
1414
import listShape from './shapes/listShape';
1515
import nodeShape from './shapes/nodeShape';
16+
import { CHECK_MODEL, KEYS } from './constants';
1617

1718
class CheckboxTree extends React.Component {
1819
static propTypes = {
@@ -67,11 +68,7 @@ class CheckboxTree extends React.Component {
6768
},
6869
iconsClass: 'fa5',
6970
id: null,
70-
lang: {
71-
collapseAll: 'Collapse all',
72-
expandAll: 'Expand all',
73-
toggle: 'Toggle',
74-
},
71+
lang: defaultLang,
7572
name: undefined,
7673
nameAsArray: false,
7774
nativeCheckboxes: false,

src/js/lang/default.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
collapseAll: 'Collapse all',
3+
expandAll: 'Expand all',
4+
toggle: 'Toggle',
5+
};

0 commit comments

Comments
 (0)