developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
#569 closed enhancement (fixed)
jLocale : support multiline rendering in strings
Reported by: | Julien | Owned by: | Julien |
---|---|---|---|
Priority: | low | Milestone: | Jelix 1.1 beta 1 |
Component: | jelix:core:jLocale | Version: | 1.0.3 |
Severity: | minor | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Documentation needed: | no | |
Hosting Provider: | Php version: |
Description
Sometimes, when we have to translate quite long texts, we may need line breaks in it.
Right now, we cannot insert \n in strings, because it won't be treated as a line break.
We already have the ability to write strings on multiple lines in the properties files, like this
mystring = This a string that will be returned\ on one line, even if it's declared on 2 lines in the property file
but the string is still returned in 1 single line.
I propose the following syntax (
at end of line) to get the string returned with a line break :
mystring = This a string that will be returned\\ with a line break
The jlocale html plugin will also be updated to render <br /> at line breaks.
Attachments (3)
Change History (19)
comment:1 Changed 13 years ago by Julien
- Status changed from new to assigned
comment:2 Changed 13 years ago by laurentj
comment:3 Changed 13 years ago by Julien
Ok for that syntax.
I think supporting \n is enough about this ticket's description, no ?
The patch would basically do something like :
$str = str_replace('\n',"\n",$str);
and the jlocale html plugin will use nl2br() PHP function to get a <br /> tag.
Changed 13 years ago by Julien
patch for handling \n in strings and getting <br /> tags with html jlocale plugin for jtpl
comment:4 Changed 13 years ago by Julien
- review set to review?
comment:5 follow-up: ↓ 6 Changed 13 years ago by laurentj
- Milestone set to Jelix 1.1 beta 1
- Priority changed from normal to low
- review changed from review? to review-
- Severity changed from normal to minor
The replacement of '\n' by "\n" should be done during the load of the ressource file, so it doesn't need to do this replacement each time we want to get the string.
I would like also a unit test on this new feature.
comment:6 in reply to: ↑ 5 Changed 13 years ago by Julien
Replying to laurentj:
The replacement of '\n' by "\n" should be done during the load of the ressource file, so it doesn't need to do this replacement each time we want to get the string.
Ok for that, no problem
I would like also a unit test on this new feature.
Ok, so I'll write a test for testing '\n' to "\n" conversion.
comment:7 Changed 13 years ago by Julien
- review changed from review- to review?
Here's the new patch. I also added a unit test, but I'm not really sure I did what you wanted to (I'm a beginner with unit tests). Don't hesitate to correct me if I'm wrong.
comment:8 Changed 13 years ago by laurentj
- review changed from review? to review-
The replacement should be done at two lines: 123 and 133, not at line 141.
str_replace(array('\#','\n'),array('#',"\n") ....);
So add a test with a multi-line string ;-)
comment:9 Changed 13 years ago by Julien
- review changed from review- to review?
Thanks for the report, I actually missed that line :(
So here's the new patch, with a new unit-test.
comment:10 Changed 13 years ago by laurentj
- review changed from review? to review+
patch is ok, thanks :-)
comment:11 Changed 13 years ago by Julien
- Resolution set to fixed
- Status changed from assigned to closed
commited
comment:12 Changed 13 years ago by laurentj
not in 1.0.x branch !
comment:13 Changed 13 years ago by laurentj
remove your patch from 1.0.x branch please
comment:14 Changed 13 years ago by Julien
removed the patch in 1.0.x
sorry for that :(
comment:15 Changed 12 years ago by laurentj
- Documentation needed set
comment:16 Changed 12 years ago by laurentj
- Documentation needed unset
I don't like this syntax. I prefer a support of classical escaped characters like \n, \r, \t etc..