Comments (7)
Maybe I'm missing something, but does this not work...?
DATA(lv_test) = |{ 'Some text'(001) } more text|.
from styleguides.
Translatable text often is a bit different, I'd argue, in that you probably shouldn't assemble it with either of those methods in the first place, but use message texts with placeholders instead, because in other languages the order of the text fragments might be different or certain grammatical constructions work differently.
For instance, non-translatably I might construct a text like
data(str) = |Customer { customer }'s total amount owed is { amount }.|.
but if you want to make this translatable, the correct way isn't to make translatable texts of the fragments
" Don't do this
data(str) = |{ 'Customer'(001) } { customer }{ '''s total amount owed is'(002) } { amount }.|.
but instead to create a message text Customer &1's total amount owed is &2.
and then use that with
message ... with customer amount into data(str).
This isn't really about readability of the code but primarily about getting good translations: While in English the possessive marker 's
appears only in text-002, and text-001 bears no case marker, in many languages the "Customer" in text-001 would need to be declined in agreement with the possessive case of the customer's name - but someone just translating text-001 can't know that (and you might even be tempted to reuse text-001 in other contexts where "Customer" appears in English but is not related to a possessive at all).
from styleguides.
Thanks for the quick reply! That might have been a combination I hadn't tried but did now and it seems to work in our NW 7.50 system. Just not really sure, what the advantage over concatenation with "&&" is which is - to me - much faster to type and interpret than the version with "|" and "{ }".
How about expanding the code example with the version for translatable text?
from styleguides.
Hi Björn,
thanks for the detailed feedback! Yes, translatable texts and whether or not a simple concatenation will do or a proper message is better will depend a lot on context. I often use the concatenation for things like header information in ALV-output and there a messages would be a bit of an "overkill" as grammer or sentence structure doesn't play a role in something like this:
CONCATENATE '# of sales-orgs:'(c01) lv_cnt_txt INTO lv_text.
For other kind of text, I am usually working with messages where that makes sense.
from styleguides.
Yeah, I think in such a simple case there isn't a lot of reasons to strictly follow the rule about using |
. Still, I personally would do it because it's good to get into the habit of using it, anyway.
from styleguides.
Just a thought: You can try to find a suitable DDIC domain for ALV headers and the likes, or there's no harm in creating one. It's possibly more efficient and definitely more reusable than a translatable text element.
from styleguides.
Since there haven't been any other arguments for a while, people seem to be generally fine with the rule in the guide staying as it is - feel free to reopen the discussion if there aren't any other edge cases to consider
from styleguides.
Related Issues (20)
- Strategy for handling dependencies to system releases HOT 4
- Text on logo not readable in dark mode (Code Review Guide) HOT 3
- [Exploit the test tools] Add CL_AUNIT_AUTHORITY_CHECK to the list? HOT 6
- [Consider decomposing complex conditions] bad use case example HOT 1
- German Translation: Typo HOT 1
- Use assert class instead of ASSERT HOT 12
- Are comments bad or not?
- [Use CHANGING sparingly, where suited] Is it ok to use IMPORTING REF instead of CHANGING? HOT 7
- New rule: prefer inferring types HOT 1
- Abap Exception categories HOT 3
- Use READ-ONLY sparingly - new abap command FINAL HOT 2
- How to add sample code to Clean ABAP? HOT 1
- Unclear explanation of [Use LOCAL FRIENDS to access the dependency-inverting constructor] HOT 5
- Follow rules when abbreviating HOT 1
- "Dead" link at section "split-method-instead-of-boolean-input-parameter" HOT 3
- Chapter "Avoid abbreviations" HOT 7
- [Prefer RAISE EXCEPTION NEW to RAISE EXCEPTION TYPE] In defense of RAISE EXCEPTION TYPE HOT 6
- Prefer ENUM to constants interfaces HOT 1
- "New rule" Tables > Prefer a Table Expression to READ TABLE HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from styleguides.