-
Notifications
You must be signed in to change notification settings - Fork 62
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
type: Code fence info string should not be translatable #194
Comments
@jonassmedegaard looking at the code, it looks like you introduced this feature, so I'm curious to hear your feedback. |
hi @eighthave - nice to "see" you :-) Code blocks embedded in markdown files is typically for documentation purposes and sometimes contain locale-specific variables or strings, especially when the "code" really is pseudo-code (which includes listings or similar which isn't really code but visually need vertical alignment of letters). I therefore find it wrong to completely skip code blocks for translation purposes. Good suggestion, however, to add a hint to translators alterting them to be cautious not to break code! |
Here's an example: https://ikiwiki.info/sandbox/ The text "with leading and enclosed spaces" is a code block which would make sense to translate. Ikiwiki was the original trigger for the code introduction to po4a for handling markdown. Here's another example where I do translate code blocks (notice the very last line before the footer): https://solidbox.org/setup/index.fr |
...but perhaps I have totally misunderstood this issue: If you are talking not about the content of code blocks, but only the optional trailing meta hints at the same line as initiating a code block, then I completely agree that it is irrelevant to translate. |
I 100% agree that translators should see the contents of the code blocks (see also #195), I'm talking about the "code fence info string", e.g. the "bash" in ```bash
for foo in bar; do
echo $foo
done
```
|
then we agree, and I apologize for not reading your initial messages closely! |
@jonassmedegaard and hello to you too :-) I'm really terrible at Perl, if you could propose a code snippet here, I could try it out and test it. Looks like removing this line is one piece of the solution: https://salsa.debian.org/mquinson/po4a/-/blob/master/lib/Locale/Po4a/Text.pm#L584 |
Quoting Hans-Christoph Steiner (2020-03-20 15:48:35)
@jonassmedegaard and hello to you too :-) I'm really terrible at Perl, if you could propose a code snippet here, I could try it out and test it. Looks like removing this line is one piece of the solution: https://salsa.debian.org/mquinson/po4a/-/blob/master/lib/Locale/Po4a/Text.pm#L584
ok, I'll have a look...
…--
* Jonas Smedegaard - idealist & Internet-arkitekt
* Tlf.: +45 40843136 Website: http://dr.jones.dk/
[x] quote me freely [ ] ask before reusing [ ] keep private
|
Quoting Hans-Christoph Steiner (2020-03-20 15:48:35)
@jonassmedegaard and hello to you too :-) I'm really terrible at Perl, if you could propose a code snippet here, I could try it out and test it. Looks like removing this line is one piece of the solution: https://salsa.debian.org/mquinson/po4a/-/blob/master/lib/Locale/Po4a/Text.pm#L584
Try this:
```diff
diff --git a/lib/Locale/Po4a/Text.pm b/lib/Locale/Po4a/Text.pm
index a81cd011..a1ab0b27 100644
--- a/lib/Locale/Po4a/Text.pm
+++ b/lib/Locale/Po4a/Text.pm
@@ -577,24 +577,20 @@ sub parse_markdown {
my $fence_space_between = $4;
my $info_string = $5;
# fenced code block
- do_paragraph($self,$paragraph,$wrapped_mode);
+ my $type = "fenced code block".($info_string?" ($info_string)":"");
+ do_paragraph($self,$paragraph,$wrapped_mode,$type);
$wrapped_mode = 0;
$paragraph="";
my $s = "";
- $s = $self->translate($info_string,
- $self->{ref},
- "Code fence info string",
- "wrap" => 0)
- if ($info_string);
$self->pushline($fence_space_before.$fence.$fence_space_between.$s."\n");
- do_paragraph($self,$paragraph,$wrapped_mode);
+ do_paragraph($self,$paragraph,$wrapped_mode,$type);
$paragraph="";
my ($nextline, $nextref) = $self->shiftline();
while ($nextline !~ /^\s{0,3}$fence$fencechar*\s*$/) {
$paragraph .= "$nextline";
($nextline, $nextref) = $self->shiftline();
}
- do_paragraph($self,$paragraph,$wrapped_mode);
+ do_paragraph($self,$paragraph,$wrapped_mode,$type);
$self->pushline($nextline);
$paragraph="";
$end_of_paragraph = 1;
```
(no, I will not make a merge request, as I am uncomfortable ever doing a
single "git push" to Github due to their terms of service)
…--
* Jonas Smedegaard - idealist & Internet-arkitekt
* Tlf.: +45 40843136 Website: http://dr.jones.dk/
[x] quote me freely [ ] ask before reusing [ ] keep private
|
That patch works perfectly! I have one small change request: follow the caps standard of po4a and make it "Fenced code block" rather than "fenced code block". This patch solves #194 and #195. Your patch found and properly generated all these:
As for making a merge request, I can make it here on GitHub, or the po4a authors have accepted your merge request on https://salsa.debian.org/mquinson/po4a before, if you want to submit. |
Quoting Hans-Christoph Steiner (2020-03-20 16:47:43)
That patch works perfectly!
In first attempt, coding blindly. Yay!
I have one small change request: follow the caps standard of _po4a_
and make it "Fenced code block" rather than "fenced code block".
Makes sense. Also: Let's expect parsers to parse case-insensitively!
Your patch found and properly generated all these:
```
#. type: fenced code block
#. type: fenced code block (apache)
#. type: fenced code block (bash)
#. type: fenced code block (conf)
#. type: fenced code block (console)
#. type: fenced code block (diff)
#. type: fenced code block (gradle)
#. type: fenced code block (nohighlight)
#. type: fenced code block (python)
#. type: fenced code block (xml)
#. type: fenced code block (yaml)
```
That reminds me: I should update+extend tests.
As for making a merge request, I can make it here on GitHub, or the
_po4a_ authors have accepted your merge request on
https://salsa.debian.org/mquinson/po4a before, if you want to submit.
I will do what I find more convenient than MR: Add a wip branch at
salsa.
If upstream dislike grabbing that directly, then I would like to take
you up on your offer to convert that into a merge request, on Salsa or
Github as you prefer.
I'll post here when I have created the wip branch.
…--
* Jonas Smedegaard - idealist & Internet-arkitekt
* Tlf.: +45 40843136 Website: http://dr.jones.dk/
[x] quote me freely [ ] ask before reusing [ ] keep private
|
Hello, I cherry-picked the commit from the repo where it was (that is dedicated to the Debian package) and pushed it to the upstream source code on both github and salsa. Thanks to both of you! |
I cannot think of any instance where the "code fence info string" should be translatable, and least in Markdown syntax. It is as much syntax as the
```
since it is keywords to specify which colorizing syntax to use. For example, in the F-Droid docs, thebash
"code fence info string" is split out as a string to translate here. At the very least, there should be an automatically generated comment saying that this rarely translated. Otherwise we will see lots of translations for syntax terms likebash
,console
, etc. which will break the syntax highlightingHere are some related docs:
@uniqx
The text was updated successfully, but these errors were encountered: