Wikimedia Developer Support

Blank lines appended to messages

i18n

#1

Hi all Some translations arriving in translatewiki.net are only because one or several blanks lines have been added to EN text. What is the rule for developpers ? Are the appended lines allowed in the messages ? Should the messages end with last non blank character ? Thanks.

Example: 

Phabricator:phabricator-diffusion-0f50f5cdbad0a3e2/

# Fetch received by "$1", forwarding to cluster host.

https://translatewiki.net/w/i.php?title=Special:Translate&showMessage=1274%3Aphabricator-diffusion-0f50f5cdbad0a3e2&group=phabricator-phabricator-diffusion&language=fr&filter=&optional=1&action=translate

Source:
https://phabricator.wikimedia.org/source/phabricator/browse/wmf%2Fstable/src/applications/diffusion/ssh/DiffusionGitUploadPackSSHWorkflow.php$30


#2

Unfortunately, the example link you posted doesn’t show anything any more. I would like to understand better what you mean when you say “blank lines have been added”? Added to the end of a message, or somewhere in the middle? Can you provide an example where this happened, ideally by naming the message key?


#3

Given that it’s a Phabricator message, probably not point in asking here. Phabricator is not a Wikimedia project, they have their own rules and probably no one here is familiar with them. Translatewiki might be a better place to ask.


#4

The question is generic; if I encounter a format imposed by the developper (here adding a newline), should the translated text keep the same format ? that means insert the new line or restricts only to the text being translated ? If I have your position of about how it should be rendered, then I can forward the problem to the translatewiki.net support team. Thanks.


#5

Ok added a snapshot of what I see on my screen. The newline impose a new translation.

     if ($device) {
    	        $this->writeClusterEngineLogMessage(
    	          pht(
    	            "# Fetch received by \"%s\", forwarding to cluster host.\n",
    	            $device->getName()));
    	      }

The link to code is the one shown in the message documentation


#6

I believe the answer must be a yes, always keep the original formatting intact. A newline at the end is typically used for messages that are meant to be printed on a terminal screen. Removing it would result in possibly unreadable output.

The only option you, as a translator, have is to tell the maintainers of the code to keep these extra newlines out of the localizable text. Instead of:

pht( "Translatable message\n" );

It should be:

pht( "Translatable message" ) . "\n";

#7

I agree with you. The newlines are ignored when presented to translators.

Task created: https://phabricator.wikimedia.org/T214040

Thanks.


#8

I would like to add a summary of my thoughts:

  • Trailing whitespace is stripped from translations, so you cannot add it even if you wanted to.
  • The Gettext file format support automatically adds a \ at the end of the message if there is a trailing whitespace, and those should be kept in translation. This does not happen with other file formats.
  • Whether the trailing whitespace is significant or not really depends on the project and the context of the message. In most cases there is no need to have trailing whitespace in the translation and it can be added in the code, but those need to be reported to upstream and hope they fix it.

#9

…so Nike what about the ‘\n’ of the developper ? should it show a backslash to the translator at the end of the text ? but there is none. More of that it is impossible (i agree with you) to add whitespace to the translation. So i cannot correct the proposed message and it is presented again and again for translation.


#10

Another case of new line still proposed for translation in a Media message -> cannot be corrected since trailing blanks are not taken into account.


#11

The latest case is better suited for Phabricator so that the extension developer can fix it.