$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: false, vro: false, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
0

string templates and text elements / translation ?

Feb 21, 2017 at 02:31 PM

256

avatar image
Former Member

Hi all,

in a normal se38 report one could write someting like

DATA: two TYPE i VALUE 2.
WRITE:  
/ 'I have '(t01) && two && ' eyes.'(t02), "I have2 eyes.  <-- wrong spacing  
/ `I have ` && two && ` eyes.`,  "I have 2 eyes. <-- ok  
/ |I have | && two && | eyes.|.  "I have 2 eyes. <-- ok

The two text symbols T01 and T02 can be translated. But I would like to use string templates because I don't want to care about trailing spaces. You can not use text symbols with string templates as far as I know.

It results in a syntax error:

/ `I have `(t01) && ... <-- Syntax error
/ |I have |(t01) && ... <-- Syntax error

Without text elements the Code Inspector complains (informational): "Strings without text elements are not translated."

Is this crippled by design? Am I missing something?

BTW: I know CONCATENATE and pragmas and a few other ways to work around. That's not the question.

10 |10000 characters needed characters left characters exceeded

Just to note that using text elements to construct sentences like

'I have '(t01)&& two &&' eyes.'(t02)

is not a good idea, as word order varies from language to language. OK, for this sentence, it works at least in French and German, but you'd get problems with

You must check the table table_name

Since the German would be: Sie müssen die Tabelle table_name kontrollieren.

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Horst Keller
Feb 21, 2017 at 02:37 PM
4

What about embedded expressions inside string templates? These work as desired.

|{ 'I have'(t01) } |
|{ text-t01 } |
Show 4 Share
10 |10000 characters needed characters left characters exceeded
Former Member

It looked promising until I tried. But you left out the important part: the trailing blank. It does not work with ` instead of '. More ideas?

0

I don't see your problem ....

|{ 'I have'(t01) } | && two && | { 'eyes'(t02) }.|

gives "I have 2 eyes."

Same for

|{ 'I have'(t01) } { two } { 'eyes'(t02) }.|
2
Former Member

My fault. I tried to stick the space to the text. But it's hidden in what i thougt was syntax. Thank you very much for explaining.

For the records (and for my future reference because I will not remember this in 100 years): Here are the blanks:

0

"But it's hidden in what i thougt was syntax"

Without embeddeed expressions in { ... }, string templates are simply a kind of string literals |...| where blanks (and especially trailing blanks) are nothing but normal characters.

Their merit of course comes with embedded expressions |...{ ... }...{ ... }...|, where inside the curly brackets you have ABAP operand positions.

Therefore writing it as

|{ 'I have'(t01) } { two } { 'eyes'(t02) }.|
makes it more clear.
1