This repository was archived by the owner on Jan 21, 2022. It is now read-only.
File tree 2 files changed +41
-7
lines changed
2 files changed +41
-7
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,37 @@ public function getMissingStringCount($locale) {
192
192
return $ i ;
193
193
}
194
194
195
+ /***
196
+ * @param $locale
197
+ *
198
+ * @return int
199
+ */
200
+ public function getMatchingStrings () {
201
+
202
+ if ($ this ->locale === null ) {
203
+ throw new Exception ('ReactIntlEditor was not instansiated with a locale ' );
204
+ }
205
+
206
+ $ matches = [];
207
+
208
+ foreach ($ this ->sourceStrings as $ sourceString ) {
209
+ foreach ($ this ->localeStrings [$ this ->locale ] as $ localeString ) {
210
+ if ($ localeString [0 ] == $ sourceString ->id ) {
211
+ $ combinedString = array (
212
+ 'id ' => $ sourceString ->id ,
213
+ 'defaultMessage ' => $ sourceString ->defaultMessage ,
214
+ 'description ' => $ sourceString ->description ,
215
+ 'message ' => $ localeString [1 ]
216
+ );
217
+ array_push ( $ matches , $ combinedString );
218
+ continue ;
219
+ }
220
+ }
221
+ }
222
+
223
+ return $ matches ;
224
+ }
225
+
195
226
/***
196
227
* @param $locale
197
228
*
Original file line number Diff line number Diff line change 14
14
$ reactIntlEditor = new \ReactIntlEditor \ReactIntlEditor ($ locale );
15
15
16
16
switch ($ type ) {
17
+ case 'matching ' :
18
+ $ stringsArray = $ reactIntlEditor ->getMatchingStrings ();
19
+ break ;
17
20
case 'missing ' :
18
- $ missing = $ reactIntlEditor ->getMissingStrings ();
21
+ $ stringsArray = $ reactIntlEditor ->getMissingStrings ();
19
22
break ;
20
23
default :
21
24
throw new \ReactIntlEditor \Exception ('Unknown String Type Specified in Querystring ' );
51
54
<button class="submitbutton">Save Changes</button>
52
55
</div>
53
56
54
- <?php $ i =0 ; foreach ($ missing as $ string ) { ?>
57
+ <?php $ i =0 ; foreach ($ stringsArray as $ string ) { ?>
55
58
56
59
<table class="translate_item" id="translate-table-<?php echo $ i ; ?> ">
57
60
<thead>
58
61
<tr>
59
- <td><span class="key"></strong><?php echo $ string ->id ; ?> </span></td>
62
+ <td><span class="key"></strong><?php echo ( $ type == ' missing ' ) ? $ string ->id : $ string [ ' id ' ] ; ?> </span></td>
60
63
<td></td>
61
64
<td>Translated Text for <?php echo $ locale ; ?> locale</td>
62
65
</tr>
63
66
</thead>
64
67
<tbody>
65
68
<tr>
66
69
<td class="original">
67
- <p><span id="original-<?php echo $ i ;?> "><?php echo $ string ->defaultMessage ; ?> </span></p>
70
+ <p><span id="original-<?php echo $ i ;?> "><?php echo ( $ type == ' missing ' ) ? $ string ->defaultMessage : $ string [ ' defaultMessage ' ] ; ?> </span></p>
68
71
</td>
69
72
<td>
70
73
<button class="copybutton" data-id="<?php echo $ i ; ?> ">Copy ></button>
71
74
</td>
72
75
<td>
73
- <textarea class="translation" name="<?php echo $ string ->id ; ?> " id="translation-<?php echo $ i ; ?> "></textarea>
76
+ <textarea class="translation" name="<?php echo ( $ type == ' missing ' ) ? $ string ->id : $ string [ ' id ' ] ; ?> " id="translation-<?php echo $ i ; ?> "> <?php if ( $ type == ' matching ' ) { echo ( $ type == ' matching ' ) ? $ string [ ' message ' ] : '' ; } ? > </textarea>
74
77
</td>
75
78
</tr>
76
79
</tbody>
77
- <?php if ($ string ->description !== null && $ string ->description !== $ string ->defaultMessage ) { ?>
80
+ <?php if ( ( $ type == ' matching ' && $ string[ ' description ' ] !== null && $ string [ ' description ' ] !== $ string [ ' defaultMessage ' ]) || ( $ type == ' missing ' && $ string ->description !== null && $ string ->description !== $ string ->defaultMessage ) ) { ?>
78
81
<tfoot>
79
82
<tr>
80
83
<td colspan="3">
81
- <strong>Context:</strong><br /><?php echo $ string ->description ; ?>
84
+ <strong>Context:</strong><br /><?php echo ( $ type == ' missing ' ) ? $ string ->description : $ string [ ' description ' ] ?>
82
85
</td>
83
86
</tr>
84
87
</tfoot>
You can’t perform that action at this time.
0 commit comments