When using the Multilingual App Toolkit extension (version 4) in Visual Studio (2015) is there any way to prevent one of the resource files in the project from being translated?
In the Multilingual App Toolkit I have two languages added using Add translation languages...
I've now added a new resource file resourceImages.resx to my WinForms project to contain images that should not be localized.
The toolkit has automatically created resourceImages.fr.resx and resourceImages.de.resx. Is there any way I can prevent this - I do not want the images to have translated versions and I don't want them to appear in the xlf translation files that our translators will receive.
The author of the Multilingual App Toolkit has now answered this question in the Q&A tab here
There is no option to ignore resource files with MAT. However, by default the entry in the XLF file is a reference to a image location and not the image itself. Marking the image resource(s) as Translate = 'No' in the XLF file will prevent the images references from being added to the target language image resource files. This is because resources with a Translate = 'No' are not added to the target resource file. This should allow you to use a single image for all languages without any project bloat.
Related
Is there any way to use images in the format .png or another format, and then compile these images so that they are not within the folder Resource of this project? I've seen several programs using many of the images as icons but when you open the folder resource the only image I see is the icon of the program.
If items such as standard system icons are used you only need their paths (since they would already be installed), otherwise the image files need to be included in the project.
I'm making app with using Xamarin.forms PCL.
I'm using localization of Xamarin, which is using resx files.
I have documents for localization on google sheet.
What I want to try to do is converting csv file to each resx file.
I'm using mac. (I also have a window machine)
Is there some converting tool or shell script for that?
Thanks.
Currently you have ResX Resource Manager as a extension for Visual Studio, running Windows. I have a mac but I manage my resx files on Windows (Parallels) with this tool.
Its a very powerful tool.
This tool provides central access to all ResX-based string resources
in your solution. You can quickly navigate through all resource files
and view the content in a well-arranged data grid. It makes it easy to
find untranslated strings or clean up orphaned entries. All strings
can be quickly edited in place, untranslated entries will be created
on the fly while typing. Excel export and import lets you easily
exchange translations outside of Visual Studio. Automated translations
can speed up you localization process.
So I understand how Multilingual App Toolkit 4.0 works and it works great for my Xamarin.Android project. The default language is English, and with MAT we've translated it to Dutch and German.
Then comes the translator along and asks about how to make changes to the English texts, which is my source texts and the basis of all translations. The source texts (English) are in a file Resources\values\Strings.xml. Alter a string there, would invalidate all translations (Dutch and German).
Besides invalidation, I can't send my translator the normal .xlf file, because all source texts are in the Strings.xml file.
So my question is, how can my translator alter the source language texts in the most easy way (preferably with an .xlf file)?
The short answer is that you can't. The design of the Multilingual App Toolkit focused on providing easy support for translation into other languages. The concept of providing source content editing was not considered.
That said, as a workaround you could add another variant of English. For Android apps, the default is English Neutral (en), so adding en-US or en-UK would create the XLIFF file that your translator / proofer could edit using the same tooling (e.g.: Multilingual Editor) to provide source content proofing. If using the same translator for proofing and translating, they could apply the translation based on the update English string to the Dutch and German files.
When you receive the XLF files back ensure all the resource in the proofing English XLF (e.g.: en-US) are marked as need review, translated or final (basically anything except 'New'). The reason is that the Multilingual App Toolkit does not include untranslated resource in the generated target resource file. (The reason is for language fallback purposes in Windows apps).
Now you can import the proofed English file with the other XLF file and build. Copy the entire contents from the proofed English resource file(s) overtop the original source files (recommend Comparing first). When you next build, you will receive warnings that the source resources have changed after the translation, but you can just review and clear those warning in the editor, or clear them globally within the Visual Studio IDE.
In a visual studio project I have three layers, Data Layer, Business Layer and Presentation Layer.
In the Data Layer I have a few XSLT's that transform some objects into an email, all works fine but I have discovered that the XSLTs do not get built/copied when building.
I have currently, created a folder in the deploy location and placed the XSLT's there but I am concerned about relying on a manual process to update these.
Has anyone encountered a similar issue and if so how did they get around it.
It smacks of changing the MSBuild script to copy the build artifacts to the required location, does anyone have examples of this?
Thaks
If you are using Visual Studio 2005/2008, the easiest way to do this is by including your XSLT files as project resources.
Open the Properties for your project.
Select the Resources tab. You will probably see a link that says "This project does not contain a default resources file. Click here to create one." Go ahead and click on that.
Click the Add Resource drop-down near the top and select Add Existing File.
Browse to your XSLT files and select them.
After you have done this, you can easily access the resources in the following manner:
// To get the contents of the resource as a string:
string xslt = global::MyNamespace.Properties.Resources.MyXsltFile;
// To get a Stream containing the resource:
Stream xsltStream = global::MyNamespace.Properties.Resources.ResourceManager.GetStream("MyXsltFile");
If you are using Visual Studio 2003, your best bet is to include those XSLT files as embedded resources for the DLL. In Visual Studio, select the file(s) in Solution Explorer, open the Properties pane, and change the Build Type to "Embedded Resource". You can then use the GetManifestResourceStream method to get a Stream containing the XSLT(s). The name to pass will be based on the default namespace of your assembly, the folder containing the file, and the name of the file.
For example, say your data layer assembly has a default namespace of My.DataLayer. Within your data layer project you have a folder named Templates which contains a file called Transform.xslt. The code to get your XSLT would look like this:
// There are numerous ways to get a reference to the Assembly ... this way works
// when called from a class that is in your data layer. Have a look also at the
// static methods available on the Assembly class.
System.Reflection.Assembly assembly = (GetType()).Assembly;
System.IO.Stream xsltStream = assembly.GetManifestResourceStream("My.DataLayer.Templates.Transform.xslt");
For more information check out this article on CodeProject.
Obvious question maybe, but still has to be asked, did you include the folder containing the XSLT's in the project itself? Is this a web or forms app?
In VS, it is easy to set the properties of the XSLT files in the project to copy on build, by default they do not.
I may have explained myself poorly.
THe Data layer is a class library that a the presentation layer references.
On building the DataLayer I can get the XSLTs to output to the Bin directory of the DataLayer. However when I build and publish the presentation layer, it correctly grabs the DLL but not the XSLTs
By default when you add an image (icon, bitmap, etc.) as a resource to your project, the image's Build Action is set to None. This is done because the image is magically stored inside a .resources file.
I want the resource to be stored as an embedded resource (my reasons are irrelevant, but let's just pretend it's so that I can see them inside RedGate's Reflector).
So I changed each image's Build Action to Embedded Resource, and the resource then appears inside Lutz's Reflector - exactly as I want.
Unfortunately, Microsoft says specifically not to do this:
Note that when the resource editor
adds an image, it sets Build Action to
None, because the .resx file
references the image file. At build
time, the image is pulled into the
.resources file created out of the
.resx file. The image can then easily
be accessed via the strongly-typed
class auto-generated for the .resx
file.
Therefore, you should not change
this setting to Embedded Resource,
because doing so would include the
image twice in the assembly.
So what is the proper way to include an image as an embedded resource?
Note: This answer is not the recommended way of handling image resources. It just addresses the particular problem as described by the question (i.e. to include an image as an embedded resourse).
Don't add the image as a resource. I would rather do the following:
Create the image/icon and save it to a file
Choose Project -> Add Existing Item and add the file
Set the Build Action to Embedded Resource
You can then access this resource using
Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceUri)
This way the image is not magically added to the projects resource file and you will only have one copy of the image stored in the assembly's resources.
In the project view, open the Properties subtree; double-click the Resources.resx item.
(If you don't have one, right-click the Properties item and choose Open, then click on the Resources tab on the left, and click the link in the middle of the page to create a default resources file.)
click the first droplist at the top of the resources.resx page. It probably says something unhelpful like "Strings", and select Images. Alternately you can press Ctrl + 2. This changes to the Image resources view. Now click the Add Resource droplist and choose 'existing file'. Select your image file and click Open. Rename the resource if you like.
Click the Save icon.
You can now access your embedded resource programmatically as:
[namespace].Properties.Resources.[yourResourceName]
In VS 2005:
Right click on your project and
choose add new item.
Add a resource file. Call is
myImages.resx
Place this file in the root folder of the project.
Right click on myImages.resx
and choose View Designer
Select Add Resource, Add Existing
file.
Browse for the image e.g. stop.bmp
This image does not have to be included in the project at this stage. The resource file will automatically do this.
To reference the image in code use something like:
btnStop.Image = myImages.Stop;
This depends on how you want to use the image.
If you want to localize and access specific images for a specific culture, then using the ResourceManager is a good way to go because it provides some nice functionality for satellite assemblies, searching, fallbacks, etc.
If you just want to embed a resource in an assembly and aren't worried about localization (using Assembly.GetManifestResourceStream) then just adding a image and setting the build action to Embedded Resource is fine.
The documentation warns you about not setting the build action to Embedded Resource because the resource is already compiled into the assembly by the resource compiler via the .resx file.