Skip to content

Commit c1a6c3c

Browse files
authored
Merge pull request #3353 from chrisgarrity/issue/3351-isRtl
Get isRtl from scratch-l10n
2 parents 8ffae77 + 8d1f64d commit c1a6c3c

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/components/sprite-selector/sprite-selector.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import SpriteInfo from '../../containers/sprite-info.jsx';
77
import SpriteList from './sprite-list.jsx';
88
import ActionMenu from '../action-menu/action-menu.jsx';
99
import {STAGE_DISPLAY_SIZES} from '../../lib/layout-constants';
10-
import {rtlLocales} from '../../lib/locale-utils';
10+
import {isRtl} from 'scratch-l10n';
1111

1212
import styles from './sprite-selector.css';
1313

@@ -140,7 +140,7 @@ const SpriteSelectorComponent = function (props) {
140140
}
141141
]}
142142
title={intl.formatMessage(messages.addSpriteFromLibrary)}
143-
tooltipPlace={rtlLocales.indexOf(intl.locale) === -1 ? 'left' : 'right'}
143+
tooltipPlace={isRtl(intl.locale) ? 'left' : 'right'}
144144
onClick={onNewSpriteClick}
145145
/>
146146
</Box>

src/lib/locale-utils.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// TODO: this probably should be coming from scratch-l10n
2-
// Tracking in https://github.com/LLK/scratch-l10n/issues/32
3-
const rtlLocales = ['he'];
1+
/**
2+
* @fileoverview
3+
* Utility functions related to localization specific to the GUI
4+
*/
45

56
const wideLocales = [
67
'ab',
@@ -16,12 +17,17 @@ const wideLocales = [
1617
'vi'
1718
];
1819

20+
/**
21+
* Identify the languages where translations are too long to fit in fixed width parts of the gui.
22+
* @param {string} locale The current locale.
23+
* @return {bool} true if translations in this language are too long
24+
*/
25+
1926
const isWideLocale = locale => (
2027
wideLocales.indexOf(locale) !== -1
2128
);
2229

2330
export {
24-
rtlLocales,
2531
wideLocales,
2632
isWideLocale
2733
};

src/reducers/locales.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {addLocaleData} from 'react-intl';
22

33
import {localeData} from 'scratch-l10n';
44
import editorMessages from 'scratch-l10n/locales/editor-msgs';
5-
import {rtlLocales} from '../lib/locale-utils';
5+
import {isRtl} from 'scratch-l10n';
66

77
addLocaleData(localeData);
88

@@ -21,7 +21,7 @@ const reducer = function (state, action) {
2121
switch (action.type) {
2222
case SELECT_LOCALE:
2323
return Object.assign({}, state, {
24-
isRtl: rtlLocales.indexOf(action.locale) !== -1,
24+
isRtl: isRtl(action.locale),
2525
locale: action.locale,
2626
messagesByLocale: state.messagesByLocale,
2727
messages: state.messagesByLocale[action.locale]
@@ -57,7 +57,7 @@ const initLocale = function (currentState, locale) {
5757
{},
5858
currentState,
5959
{
60-
isRtl: rtlLocales.indexOf(locale) !== -1,
60+
isRtl: isRtl(locale),
6161
locale: locale,
6262
messagesByLocale: currentState.messagesByLocale,
6363
messages: currentState.messagesByLocale[locale]

0 commit comments

Comments
 (0)