If you translate from German to English with memoQ, this one’s for you. In a previous post I shared a number of special rulesets for taking English long dates (and some other forms) and converting them to quite a number of different target language formats, because the majority of my readers probably have English as the source language for their translations, and if the rules I distributed don’t cover their target languages, adaptation is fairly simple.
But for 24 years I was a commercial German to English translator, and when I began using memoQ I created quite a number of rules for my own work, conforming to the requirements and styleguides of various clients. I’m sharing two of those with you today, along with a little guidance for further adaptations if desired.
One of the rulesets as distributed will take German long and short dates in usual formats and convert them to a US long date, the other will produce long dates according to UK conventions. In the screenshot above, I have both sets of rules loaded, which of course you wouldn’t do in a real project, and I’ve done the same in the demonstration video below for convenience.
The video also shows some of the flaws and fault tolerances in the rules as distributed, though the “April bug” and the incorrect name for the US-formatted date rules are fixed. The “errors” are there simply as hints for where a mistake might be made when you do your own rules and to show that you can rename rules as you like when importing them.
There are a few flaws in the rules, which probably don’t matter in most cases. There is no plausibility check on the numbers for dates, so if the source has a “date” like “33 August 2022” it will be processed as if it were a correct date. The only plausibility check on the numbers occurs for months in the German short dates. This is easy to fix using guidance in other rules I’ve distributed or by consulting examples in Anthony Rudd’s books or elsewhere. We can discuss this and other possible improvements in the Regex Assistant class next month in later sessions discussing a bit of syntax.
In the video you’ll also see that month + year and day + month date information isn’t handled. If you want that, guidance will be found in the previously distributed date rule examples. We can also cover that later in syntax discussion for the class or here in the comments.
The problem with April was because I forgot to abbreviate the month in the translation pair list, as you can see in the integrated rules editor or in the exported resource viewed in Notepad++ or another text editor:
Some changes you might want to make:
Get rid of the conversion for German short dates to English long dates if you don’t want that. It was part of the guidelines ages ago for the job that led me to make these rules. That would be the rules mentioning the
#month-num-to-text#
group.Modify the non-breaking spaces in the output. If you don’t want any of the nonbreaking spaces (represented by Unicode
\u00A0
) just overtype them with an ordinary space.Change the target language! Just rewrite the translation pairs list for months to use whatever language you need and alter the replacement rules to fit the format for that language.
Add plausibility checks (as discussed above) or additional idiot-proofing if you expect or encounter other routine errors. When I get a lot of texts written by people who aren’t natives in the source language, I go farther with allowances for bad spelling or formatting customary in a language other than the actual source language. Life is messy, and source texts often are as well, so I just code my way around the problems where I can. Ask advice for that in the comments if you need it.
The downloadable *.zip file with the rules also contains a text file with the test data seen in the video.
I have rules like these for quite a few source languages, so if there is something particular you need, just let me know and I can include it in a future tips post.
And here is the link to the download package for those who need it:
Keep reading with a 7-day free trial
Subscribe to memoQuickies Substack to keep reading this post and get 7 days of free access to the full post archives.