xliff file: Change source-language to "Base"? - xcode

I originally develop an app in English, then translating it to German.
During the course, instead of changing the files in the Base Localization, I added an English localisation to accommodate changes. I thought that was smart …
Now I got back xliff files from some (non professional) translators. The source-language attribute is "en".
However, upon import, Xcode now complains that there is a mismatch, with this example:
In my Localizable.strings file for English, there is
"%d. What you should do:" = "%d. What you should do next:";
In the Xliff there is:
<file original="Foo/en.lproj/Localizable.strings" source-language="en" datatype="plaintext" target-language="fr">
<body>
<trans-unit id="%d. What you should do:">
<source>%d. What you should do:</source>
<target>%d. Ce que vous devriez faire :</target>
<note>No comment provided by engineer.</note>
</trans-unit>
Xcode complains when importing, because "%d. What you should do:" is not "%d. What you should do next:"
Is there any way to tell Xcode to just use it? To use the "Base" Localization as reference instead of the en?
Or is there another way besides me changing all the strings?

Related

When do I need to use x-default for hreflang?

I run a site in Belgium for which default language is Dutch. Using a selector the user can translate the page into English and French.
When entering the site for the first time it's served in Dutch:
http://example.com/articles/my_article/
The language switcher gives you this English version (this places a language cookie for English):
http://example.com/my_article/?lang=en
The language switcher gives you this French version (this places a language cookie for French):
http://example.com/my_article/?lang=fr
The language switcher gives you this Dutch version (this places a language cookie for Dutch):
http://example.com/my_article/?lang=nl
Now I use the following canonical and alternate hreflang tags on this page:
<link rel='canonical' href='http://example.com/my_article/'/>
<link rel='alternate' hreflang='nl' href='http://example.com/my_article/?lang=nl'/>
<link rel='alternate' hreflang='en' href='http://example.com/my_article/?lang=en'/>
<link rel='alternate' hreflang='fr' href='http://example.com/my_article/?lang=fr'/>
The problem is, when you go back to the following URL after visiting a URL with lang=xy then it'll be served in the language based on the cookie that was previously set:
http://example.com/articles/my_article/
Does that mean I should add x-default for this page?
<link rel="alternate" href="http://example.com/my_article/" hreflang="x-default" />
From my understanding, that is the way it is supposed to work. Once users select a language, they see the content in that language.
X-default should point to a "language/region/country selection page".
In this case, it could be example.com/welcome that shows a menu to select a preferred language.
So x-default should not show any particular language page version. Like, choosing English to be x-default (example.com/my_article/?lang=en). No. It should point to the language selection page, like a welcome page. That page should be written in whatever language you think is the safest "catch-all", with a design that's easy to navigate even if you don't speak it (country flags with language name written in the language of the country, stating something like "English language site version" or whatever you think explains it the best).
Google explains it here:
https://support.google.com/webmasters/answer/189077?hl=en

Richer Coloring and Typesetting in DDoc Output

Can I make the generated HTML page from my DDoc-marked-up D program use richer coloring and type-setting? The default is black-and-white.
I'm currently calling DMD as
dmd -debug -gc -unittest -D -Dd$OUTPUT_DIR
Well, you should probably read through http://dlang.org/ddoc.html to get some of the details, but ultimately, what you need is a css file which tells it how to present the page. That can be set via the DDOC macro.
What I'd suggest doing is taking a look at https://github.com/D-Programming-Language/dlang.org, which contains the code for dlang.org - including the ddoc stuff. In particular, you want to grab std.ddoc along with the css, images, and js folders (as they are all referenced by std.ddoc). If you then give std.ddoc to dmd as part of your documentation build and have those folders in the parent directory of the documentation, the generated documentation should end up looking like the documentation on dlang.org. If you want to put the folders elsewhere, then just tweak the paths to them in std.ddoc.
If you want to change what the documentation looks like, just adjust std.ddoc and the css files accordingly. At that point, it's html and css stuff that you're dealing with, so you'll have to have some clue how those work to make the necessary changes to either the macros in std.ddoc or to the css files themselves. And of course, if you want to do anything with the js files, you'll need to know javascript. You can strip out all of the js and images if you want to. They're just what's used for dlang.org, but again, you'll have to have some clue how html and friends work to know what to do with that. I'm not particularly well versed in any of that, so when I've generated documentation, I've typically made only minimal changes to what dlang.org uses, but all I've typically been looking for is to get more legible colors than the default rather than anything specific.
Sorry that I can't be more specific or helpful than that, but the best that I've done with it is stumble through it enough to get pages looking like dlang.org, since I know next to nothing about web development. Hopefully this will point you in the right direction though.
Something else that you might want to look into is ddox, which uses ddoc comments to generate better looking documentation than dmd does. And it's likely that dlang.org will be switching to using ddox-generated documentation sometime in the relatively near future (some of the details still need to be sorted out, so I don't know when exactly, but that's the current plan). So, using ddox may ultimately end up becoming more common than using dmd to generate the documentation.
You can create your own .ddoc config file in which you override or create new ddoc macros to use class names and id's. Then you can style the page using CSS.
Sample .ddoc file containing custom CSS, Notice the theme.css file in the head HTML section:
DDOC = <!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link type="text/css" href="theme.css" rel="stylesheet" media="all" />
<title>$(TITLE)</title>
</head>
<body>
<h1>$(TITLE)</h1>
$(BODY)
</body>
</html>
H2 = <h2>$0</h2>
H3 = <h3>$0</h3>
STRONG = <strong>$0</strong>
EM = <em>$0</em>
DDOC_DECL = $(H2 $0)
DDOC_DECL_DD = <div class="declaration-description">$0</div>
DDOC_CLASS_MEMBERS = <div class="class-members">$0</div>
DDOC_SUMMARY = $(P $0)
DDOC_DESCRIPTION = $(P $0)
DDOC_MEMBERS = <div class="members">$0</div>
DDOC_ENUM_MEMBERS = <div class="enum-members">$0</div>
DDOC_MODULE_MEMBERS = <div class="module-members">$0</div>
DDOC_STRUCT_MEMBERS = <div class="struct-members">$0</div>
DDOC_TEMPLATE_MEMBERS = <div class="template-members">$0</div>
This file should be saved somewhere and added to the sc.ini file (in the case of Windows) or the dmd.conf file (in the case of Mac/Linux) like this:
DDOCFILE=myproject.ddoc
Then the next time you compile using -D, HTML is read from the custom ddoc macros instead of the built-in stuff and viola, you have style-able class names and id's to use with CSS.
Here's a preview of pretty documentation using a custom style-sheet and macros: http://htmlpreview.github.io/?https://github.com/kalekold/dunit/master/docs/dunit/toolkit.html
HTML files: https://github.com/nomad-software/dunit/tree/master/docs/dunit
Full ddoc macro listings can be found here: http://dlang.org/ddoc.html

Loading different css files or images based on locale in Rails application

So I have my simple rails application (not data driven), and I have managed (with help from Stackoverflow) to localize it. So I can view the web application in English or German. I have done so using the bundled i18n library. All is good, it was a joy to work with.
Now however, I want to load different images and or css files depending on what locale is active. I want a neat solution to this problem. Not an:
if i18n.locale = "en"
// show this particular image
else
// show that particular image
The above is not neat in my opinion, and imagine how long the if statement or switch statement will get the more locales one adds.
So I was thinking, is there a way I can extend the functionality of the javascript_include_tag, the stylesheet_link_tag and finally the image_tag to allow for locale handling?
I think something like:
stylesheet_link_tag "default.css", :locale => true
Would be nice to have, where if true, the inserted stylesheet will be like:
<link href="stylesheets/default.es.css" type="text/css" rel="stylesheet" />
Assuming my new locacle is Spanish. That would be lovely and clean.
Can this be achieved in Ruby on Rails? If yes, I would love some code sample, since I am relatively a n00b to rails.
Thank You.
You can just reference the locale when including an asset. Let's say you want to include a stylesheet specific to the current locale :
stylesheet_link_tag "custom_#{I18n.locale}.css"
If the current locale is en, this will look for the custom_en.css file.
A word of warning though : you should make sure to create a file for each locale that you intend to use.

Extending language definitions (for code highlighting) in notepad++

I've been doing development in TWIG lately. It is an html templating language that is very simple and robust.
I've set notepad++ to automatically treat .twig files as html. This is ok, but I don't get any syntax highlighting on my twig functions.
The twig syntax is incredibly simple (by design) and would be easy to add to notepad++. The problem is, everything I find on this subject is either about creating a new language definition (and I do not want to reinvent the html definition), or modifying the color for existing syntax bits in a language.
Is there any way to copy a language definition and then modify it in notepad++? If not, is there any way in notepad++ to add extra syntax bits to an existing language definition?
edit
TWIG is an html template language/engine. they syntax for it is the same as html, with the addition of a few open/close tags (specifically {% %}, {{ }}, and {# #}) for control statements. you can read more about it at the twig website
edit #2
Based on the answer from Brian Deragon, I have been investigating 3 files. Heres what I've figured out/done so far:
\plugins\APIs\html.xml - Seems to define keywords, for autocomplete. I made a copy of the file named twig.xml
langs.model.xml - Again, a list of keywords, with all the languages in 1 XML file. I copied the HTML object and replaced the name and ext parameters with twig.
stylers.model.xml - Has a list of different items, and style information (color, bg color, font, etc) for each. I copied the HTML section and changed the name and desc parameters to twig.
Those changes done, I opened up a twig file in notepad++, hoping to see it listed in the language options. Sadly, it has not appeared, leading me to believe that some of this is hard coded (and thus what I want might not be possible).
The stylers.model.xml is interesting, though. Each entry has a bunch of items, defined like this:
<LexerType name="twig" desc="TWIG" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="COMMENT" styleID="9" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="TAG" styleID="1" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="TAGEND" styleID="11" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
...
</LexerType>
Those seem to be where the styles are defined for the different elements. I can't find anywhere where those elements are defined though. langs.model.xml has a definition for comment start/end, but not for any other delimiters. what I really need is a place to tell notepad++ to treat { } as a delimiter, much like it does for < > now.
edit #3
I am also looking at this list of user defined languages for notepad++ http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=User_Defined_Language_Files
User defined languages use a different engine, but i might be able to find one in there that is similar to html enough that I can adapt it.
You should be able to just copy and edit the XML definition file (html.xml); as long as you don't need stuff beyond the basics, like code-folding, advanced coloring based off of case-handling blocks or multiple conditionals, separate formatting for lead characters, label coloring, xml-based commenting, language mixing (coloring of embedded scripts), support for coloring of duck-types, etc. If you need anything "advanced" you need to write your own lexer, in which case most of the below applies.
Even still, the templates I listed below should give you a head-start on your own language definition file.
As far as I'm aware, Notepad++ uses Scintilla Lexers for determining its code rules.
You'll have to create your own lexer, but...the HTML Scintilla Lexer is already included in the Scintilla source code.
Then you would insert your custom lexer using a plug-in, like Gary's Lua Highlighter Plugin.
Resources for building a custom lexer:
How to write a scintilla lexer
That being said, Geany is very similar to Notepad++ (based off the same engine, Scintilla), so you might want to see whether it's already been done for Geany, or whether there's an open-source project for it in the works. This would at least give you a head start.
If that doesn't help, there are IDEs and editors with Twig support built-in, like:
Eclipse
Netbeans
GEdit (which has a Windows binary, if needed)
JetBrains PhpStorm
GEdit has published their XML definition of the language here, which might help as a reference when creating your own definition file or lexer; there's also another template published by the guys from Twig here that might be of some help.
Here are the best Notepad++-specific tutorials for creating custom lexer's/User Defined Languages I can find:
User Defined Languages
How to create a user-defined language in Notepad++ based on an existing language?
If you want to get brave and build your own Scintilla dll, reference these threads, to see a guy who got it working, and to show up in the language list (use the previous/next thread message to see responses, or the thread index; it's a mailing list, so its UI isn't the best)
http://osdir.com/ml/editors.notepad++/2007-02/msg00021.html
Hope that helps or gets you at least more of a head start!
I made a Highlighter for it here:
https://github.com/Banane9/notepadplusplus-twig
Possible duplicate of this post: https://superuser.com/questions/40876/assigning-custom-extensions-to-a-languages-syntax-highlighting-in-notepad
All you need to do is add your custom extension in Settings->Style Configurator
Click on HTML and add your extension in the User Ext box.
EDIT: If you want to add more rules to your language, you might have to add another XML in notepad++->plugins->APIs
If you think it's like HTML, just copy over html.xml and save as twig.xml
Add more rules to this XML file

Possible to have Visual Studio TODO comments in aspx/ascx files appear in task list?

We develop asp.net webforms using visual studio 2008. For multilingual support, we translate all our text. However, when designing, we usually just enter the english text and come back to translation later (it interrupts flow of work otherwise).
I've added a "ToTranslate" tag in the options. Adding //ToTranslate: something in C# code correctly adds the entry to the Task List. I haven't however figured out how to do the same for aspx and ascx files (where most of our user text lives).
Inserting <%-- //ToTranslate: something --%> or <%-- ToTranslate: something --%> doesn't work.
Any ideas?
It seems to me that it works fine if you put the delimiters <% and %> on a line by themselves. What I did was this: go to Tools menu and click on Options, then under Environment -> Task List add a new ToTranslate token. Click OK to accept the change. Back on the ASPX page I added the comments on a line by themselves and the code delimiters on lines by themselves.
FYI if you want to do this in a .Net MVC3 razor cshtml file the syntax this:
#{
//TODO: Move this inline <style> css to a file
}
Take note: that you need to put the trailing } bracket on a new line as otherwise it will be included in the // comment. You could do it using /**/ like below and keep it all on one line but it's more typing, and a bit harder to read. My take is, if it annoys you the comment takes up 3 lines in your file, all the more motivation to fix the issue and remove it completely :)
#{/*TODO: Move this inline <style> css to a file*/}
You do not need the <% %> on lines by themselves. This example shows what works and what does not:
<%//ToTranslate will work%>
<%/*ToTranslate will work*/%>
<!--ToTranslate won't work-->
<!--
ToTranslate won't work
-->
It may be due to the fact that what's differentiating between an HTML comment and some form of aspx comment is getting messed up by the -- because that's part of an html comment?

Resources