Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write wrapped messages back #65

Closed
AlexanderHH opened this issue Oct 4, 2017 · 0 comments · Fixed by #68
Closed

Write wrapped messages back #65

AlexanderHH opened this issue Oct 4, 2017 · 0 comments · Fixed by #68

Comments

@AlexanderHH
Copy link

It looks like by default the strings will be wrapped. Like msgid and translated strings msgstr. Poedit and the unix-command msgmerge write the long strings wrapped. It would be good, if it will be possible to set the additional parameter somewhere, like in the writeFile method. to wrap long strings.

I wrote thid code for my project:

if (is_array($msgstr)) {
	foreach ($msgstr as $n => $mstr) {
		$entry['msgstr[' . $n . ']'] = [];

		$mstr = trim($mstr);

		$subentries = explode("\n", wordwrap($mstr, 75));
		if (count($subentries) == 1) {
			$entry['msgstr[' . $n . ']'][] = $mstr;
		} else {
			$entry['msgstr[' . $n . ']'][] = '';
			foreach ($subentries as $nr => $subentry) {
				$entry['msgstr[' . $n . ']'][] = $subentry . ($nr < count($subentries) - 1 ? ' ' : '');
			}
		}
	}
}

By the way, I have no idea, why in case of multiline (in the .po file) the first entry is the empty string:

#: stuff/xxx.php:12
#, php-format
msgid ""
"%s yyy1 sdf jsdlf slfd lsfd lfj lfdg lfdg dlfgj dlfgj dlgj fdlgjdfl gfdlgj "
"dfgj dflgj dlj glfdg lglk jldfgj fdklgj fdlgj fdgjgl dfgl jglkjg lfdjg "
"lsfdjskl dg 111111111"
msgid_plural ""
"%s yyy2 sdf jsdlf slfd lsfd lfj lfdg lfdg dlfgj dlfgj dlgj fdlgjdfl gfdlgj "
"dfgj dflgj dlj glfdg lglk jldfgj fdklgj fdlgj fdgjgl dfgl jglkjg lfdjg "
"lsfdjskl dg 2222222222"
msgstr[0] "%s 111aa"
msgstr[1] ""
"%s 222 f j k l l o k j h j h k k j h z f j k l l o k j h j h k k j h z f j "
"k l l o k j h j h k k j h z f j k l l o k j h j h k k j h z f j k l l o k j "
"h j h k k j h z f j k l l o k j h j h k k j h z f j k l l o k j h j h k k "
"kkk"
msgstr[2] ""
"%s 3333 f fdg fkgj fdjg fdkjg dlfjg fdlkj fdljdklg jfdlgj dklgj ljdflg "
"jfdlgj dflgj fdkljf glkfdjg kfdgj dkljfdl gfdkg fkgj fdlgj flgkj sklgj "
"fdklgj fdklgj sfdkl gjsfdklgjsfdklj gjfdkg sdlk33333333a aa"

@pherrymason pherrymason mentioned this issue Feb 2, 2018
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant