Browse Source

Fix proxiwash translations not loading

Arnaud Vergnet 3 years ago
parent
commit
da55abed8f

+ 13
- 13
src/components/Lists/Proxiwash/ProxiwashListItem.tsx View File

@@ -67,22 +67,22 @@ const styles = StyleSheet.create({
67 67
   },
68 68
 });
69 69
 
70
-const stateStrings: {[key in MachineStates]: string} = {
71
-  [MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.states.ready'),
72
-  [MachineStates.RUNNING]: i18n.t('screens.proxiwash.states.running'),
73
-  [MachineStates.RUNNING_NOT_STARTED]: i18n.t(
74
-    'screens.proxiwash.states.runningNotStarted',
75
-  ),
76
-  [MachineStates.FINISHED]: i18n.t('screens.proxiwash.states.finished'),
77
-  [MachineStates.UNAVAILABLE]: i18n.t('screens.proxiwash.states.broken'),
78
-  [MachineStates.ERROR]: i18n.t('screens.proxiwash.states.error'),
79
-  [MachineStates.UNKNOWN]: i18n.t('screens.proxiwash.states.unknown'),
80
-};
81
-
82 70
 /**
83 71
  * Component used to display a proxiwash item, showing machine progression and state
84 72
  */
85 73
 class ProxiwashListItem extends React.Component<PropsType> {
74
+  static stateStrings: {[key in MachineStates]: string} = {
75
+    [MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.states.ready'),
76
+    [MachineStates.RUNNING]: i18n.t('screens.proxiwash.states.running'),
77
+    [MachineStates.RUNNING_NOT_STARTED]: i18n.t(
78
+      'screens.proxiwash.states.runningNotStarted',
79
+    ),
80
+    [MachineStates.FINISHED]: i18n.t('screens.proxiwash.states.finished'),
81
+    [MachineStates.UNAVAILABLE]: i18n.t('screens.proxiwash.states.broken'),
82
+    [MachineStates.ERROR]: i18n.t('screens.proxiwash.states.error'),
83
+    [MachineStates.UNKNOWN]: i18n.t('screens.proxiwash.states.unknown'),
84
+  };
85
+
86 86
   stateColors: {[key: string]: string};
87 87
 
88 88
   title: string;
@@ -146,7 +146,7 @@ class ProxiwashListItem extends React.Component<PropsType> {
146 146
       ? `${props.item.startTime}/${props.item.endTime}`
147 147
       : '';
148 148
     const stateIcon = ProxiwashConstants.stateIcons[machineState];
149
-    const stateString = stateStrings[machineState];
149
+    const stateString = ProxiwashListItem.stateStrings[machineState];
150 150
     let progress;
151 151
     if (isRunning && props.item.donePercent !== '') {
152 152
       progress = parseFloat(props.item.donePercent) / 100;

+ 13
- 13
src/screens/Proxiwash/ProxiwashScreen.tsx View File

@@ -46,18 +46,6 @@ import MascotPopup from '../../components/Mascot/MascotPopup';
46 46
 import type {SectionListDataType} from '../../components/Screens/WebSectionList';
47 47
 import type {LaundromatType} from './ProxiwashAboutScreen';
48 48
 
49
-const modalStateStrings: {[key in MachineStates]: string} = {
50
-  [MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.modal.ready'),
51
-  [MachineStates.RUNNING]: i18n.t('screens.proxiwash.modal.running'),
52
-  [MachineStates.RUNNING_NOT_STARTED]: i18n.t(
53
-    'screens.proxiwash.modal.runningNotStarted',
54
-  ),
55
-  [MachineStates.FINISHED]: i18n.t('screens.proxiwash.modal.finished'),
56
-  [MachineStates.UNAVAILABLE]: i18n.t('screens.proxiwash.modal.broken'),
57
-  [MachineStates.ERROR]: i18n.t('screens.proxiwash.modal.error'),
58
-  [MachineStates.UNKNOWN]: i18n.t('screens.proxiwash.modal.unknown'),
59
-};
60
-
61 49
 const REFRESH_TIME = 1000 * 10; // Refresh every 10 seconds
62 50
 const LIST_ITEM_HEIGHT = 64;
63 51
 
@@ -98,6 +86,18 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
98 86
     );
99 87
   }
100 88
 
89
+  static modalStateStrings: {[key in MachineStates]: string} = {
90
+    [MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.modal.ready'),
91
+    [MachineStates.RUNNING]: i18n.t('screens.proxiwash.modal.running'),
92
+    [MachineStates.RUNNING_NOT_STARTED]: i18n.t(
93
+      'screens.proxiwash.modal.runningNotStarted',
94
+    ),
95
+    [MachineStates.FINISHED]: i18n.t('screens.proxiwash.modal.finished'),
96
+    [MachineStates.UNAVAILABLE]: i18n.t('screens.proxiwash.modal.broken'),
97
+    [MachineStates.ERROR]: i18n.t('screens.proxiwash.modal.error'),
98
+    [MachineStates.UNKNOWN]: i18n.t('screens.proxiwash.modal.unknown'),
99
+  };
100
+
101 101
   modalRef: null | Modalize;
102 102
 
103 103
   fetchedData: {
@@ -205,7 +205,7 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
205 205
       icon: '',
206 206
       onPress: () => undefined,
207 207
     };
208
-    let message = modalStateStrings[item.state];
208
+    let message = ProxiwashScreen.modalStateStrings[item.state];
209 209
     const onPress = () => this.onSetupNotificationsPress(item);
210 210
     if (item.state === MachineStates.RUNNING) {
211 211
       let remainingTime = parseInt(item.remainingTime, 10);

Loading…
Cancel
Save