i18n translation key/value pairs - internationalization

How do you recommend to name the translation keys ?
Should I use the actual text (that needs to be translated) as the translation key ?
e.g.
Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo.=But I must explain to you how all this mistaken idea of denouncing of a pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.
Or should I use keys like
content_lorem_ipsum_par_1=But I must explain to you how all this mistaken idea of denouncing of a pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.

There are times when, due to context and grammatical differences, a same piece of text in your base language has to be translated differently in two different places. This might be a problem if you use the former, so I advise to use the latter approach.

Related

Why does endianness is a concern regarding to binary files?

I have read that endianness is a problem when talking about binary files, but I have'nt found a reason for that.
Why is that? Also why isn't it apply to text files (that are in defintion binary files that just get a different interpretation).
Endianness is order within byte subsequences, necessarily of size over 1.
Take names, for example. In English, first names come... well, first. Then last names. For clarity, let's say that the given name precedes the family name. So "Thomas Edison, Nikola Tesla, Jack Nicholson" describes three people, whose given names are Thomas, Nikola and Jack. In Japan, family names come first, and given names follow. So e.g. "Kitano Takeshi" has Kitano as family name, and Takeshi as given name; and in English we usually write "Takeshi Kitano". Now if you aren't familiar with Japanese names or the pop culture, and you read "Shiina Ringo", you can't know if "Shiina" is a given name or a family name, unless someone informs you if "Shiina Ringo" is written in Japanese order or English order. (It's in Japanese order, "Shiina" is the family name.)
As long as you're inside the same culture, there's hardly any problem. Nobody in America would look at "Jack Frank" and doubt whether "Jack" or "Frank" was the given name. But if you go to a culture with the opposite order, suddenly a ton of problems. I live in Japan, and I have been randomly addressed as both "Mr $GivenName" and "Mr $LastName", simply because they had no idea whether I wrote my name using the Japanese or Western tradition.
On the other hand, people with mononyms don't have that problem. "Jennie" (the K-pop idol) is just "Jennie". "Cher" is just "Cher". There's no problem with "which one is the last name" when they don't use a last name.
Similarly, 16-bit integers take two bytes to represent. For example 0xDEAD can be represented as 0xDE 0xAD ("big endian"), or 0xAD 0xDE ("little endian"). Conversely, if you encounter 0xDE 0xAD, without knowing its endianness, you can't know if it's supposed to be 0xDEAD, or 0xADDE.
Just like with names, it usually doesn't bite you as long as you're working within the same system. Almost everything on a Windows 10 machine is little-endian. Working on a big-endian system (if you can find one, they're kind of extinct by now) will also not make problems. But if you make a little-endian file on Windows 10 and put it without change on a big-endian system without compensating for it, you'll get garbage.
Why doesn't it apply to text files? Just like why no-one messes up "Cher": when you have a stream of single bytes like e.g. 0x40, it's 0x40 whether you write it first-byte-first, or first-byte-last. (Also, note that this is only true for text files in single-byte encodings, like ASCII, Latin-1 etc. Text files with multibyte encodings like UTF-8, UCS-2, Shift-JIS, Big5 etc are all affected by endianness.)

How to handle different prepositions in internationalization?

I'm currently working on an application which I plan translate in the future (right now it's only in English).
I would like to have a resource file for each language and just put the appropriate string where needed. I don't know how to solve the following problem:
Example (English -> French):
It's raining in Paris -> Il pleut à Paris.
It's raining in Massachusetts -> Il pleut au Massachusetts.
(Sorry if the sentences in French are wrong, I translated them using Google Translator. I only want them to help me explain my problem.)
The thing is, the sentences in French have different prepositions depending on where it is raining. Is there any best practice regarding this? I can't just pull "It's raining in" from the resource file and append the location.
The project I'm working on is a web application in JavaScript.
Thanks.
Please provide more detail, what kind of app are you making?
You can just, as you stated, pull the string up until a variable "It's raining in" or you can split the sentence to say "start of sentence" variable "end of sentence". And if in English it's not the same then just use the "start of the sentence" and leave the "end of the sentence" empty. If I understood you correctly.

What means donna in cryptography?

I've often see the word "donna" in some cryptography algorithm implementations. So what it means?
Example: poly1305-donna, curve25519-donna and etc.
The poly1305-donna implementation was written by Andrew Moon, who states the following on naming his project at GitHub:
I borrowed the idea for these from Adam Langley's curve25519-donna,
hence the name.
And Adam Langley, who is the author of curve25519-donna, runs a weblog about security and cryptography with his email address on (agl AT imperialviolet DOT org). Furthermore, he also has a Twitter account.
So if you are really interested, maybe just drop him a line. I'd suppose, it simply is his wife's name. Or maybe it is related to the term prima donna, who is the leading female singer in the opera, to emphasize the algorithm's supremacy? But again, just guessing.

FPDF: Printing the text from another PHP echo

I'm trying to figure out how to print out dynamic content without creating a physical TXT file to print the data from.
In other words, I'm calling mytext.php and writing the contents out ... mytext.php looks like this:
<?php echo "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
And the PDF is generated with literally ALL of that within the text ... so <?php echo "Lorem..."
What's the best way to print dynamic content?
What I usually do is assemble the dynamic content (query the db, using post-variables ...) from within the script that generates the pdf.
If that is not necessary and the php-script you're calling outputs plain text, you could use output buffering.
There is a question that has already been asked here that holds the answer:
Read echo'ed output from another php file.
So basically, you put the output in a variable and using the FPDF Write, Cell or Multicell-function, place it inside your pdf.

Cucumber: When to use tags/hooks vs backgrounds

I was wondering if there is a good argument for or against using backgrounds in cucumber when compared to using tags and hooks.
Having a logged in user before the start of a test could go either like this:
Background:
Given that I am logged in
Scenario: Lorem ipsum sit amet dolor
[...]
or like this:
#login
Scenario: Lorem ipsum sit amet dolor
[...]
+
before(#login) do
visit('/admin/login/testuser')
end
Any idea when to favor one over the other?
Background is useful when you provide common customer-readable (non technical) background for your scenarious. It is worth using it if you want to be explicit about this initialization in the text of your Feature.
But sometimes teardown (and setup) logic is an implementation details and is implemented in Before, After or Around hooks (because reader of your spec won't need to know about these technical things).
Summary: use Background if you want to inform reader of your spec of the background and use hooks when background is an implementation details.
In you example Background is the best choice.
Definitely the former (IMHO), since it captures everything in the universally readable Gherkin feature file. The tags are only really there to help the runner - they are implementation level. What you describe here is part of the description of what is going on.

Resources