@@ -56,20 +56,31 @@ public static function handleArray(array $content, Translations $translations)
5656 $ translations ->setDomain ($ translations_info ['domain ' ]);
5757 }
5858
59- $ context_glue = '\u0004 ' ;
60-
6159 foreach ($ content as $ key => $ message ) {
62- $ key = explode ($ context_glue , $ key );
60+ static ::insertTranslation ($ translations , $ key , $ message );
61+ }
62+ }
6363
64- $ context = isset ($ key [1 ]) ? array_shift ($ key ) : '' ;
65- $ original = array_shift ($ key );
66- $ plural = array_shift ($ message );
67- $ translation = array_shift ($ message );
68- $ plural_translation = array_shift ($ message );
64+ /**
65+ * Extract and insert a new translation
66+ *
67+ * @param Translations $translations
68+ * @param string $key
69+ * @param string $message
70+ */
71+ protected static function insertTranslation (Translations $ translations , $ key , $ message )
72+ {
73+ $ context_glue = '\u0004 ' ;
74+ $ key = explode ($ context_glue , $ key );
6975
70- $ entry = $ translations ->insert ($ context , $ original , $ plural );
71- $ entry ->setTranslation ($ translation );
72- $ entry ->setPluralTranslation ($ plural_translation );
73- }
76+ $ context = isset ($ key [1 ]) ? array_shift ($ key ) : '' ;
77+ $ original = array_shift ($ key );
78+ $ plural = array_shift ($ message );
79+ $ translation = array_shift ($ message );
80+ $ plural_translation = array_shift ($ message );
81+
82+ $ entry = $ translations ->insert ($ context , $ original , $ plural );
83+ $ entry ->setTranslation ($ translation );
84+ $ entry ->setPluralTranslation ($ plural_translation );
7485 }
7586}
0 commit comments