I'm following this tutorial that was given as answer in this question, however I'm stuck at displaying the resource.
Just like in tutorial I've created two files
App_GlobalResources
/Global.en.resx
/Global.ru.resx
I've made data annotation class that works and adds a cookie with no errors, it means it injects the local data into current thread properly. When I try to output resource it cannot find it.
I've tried to output it like this and none of these works:
#Global.HomeHello
#Global.en.HomeHello
#Resources.Global.Homhello
// The name 'Resources/Global/etc...' does not exist in the current context
Also, in this tutorial site I see no logic that will inject the proper resource file, how it can do something like (in tutorial) #Global.HomeHello and it will know that if url is /en/ he needs to use Global.en.resx
Please help, first time using resources and implementing multiple languages, feels 100 times more harder and confusing than using *.yml files in other frameworks/languages...
You took a bad example to follow I guess. Please look into the following article:
Resource Files and ASP.NET MVC Projects
Don't forget to change Custom Tool to PublicResXFileCodeGenerator and Custom Tool Namespace to Resources.
Hope this helps & good luck.
Related
Normally, when you read about localization resources (RESW) for a universal application you are asked to create a single resource file for each language with Resource.resw name or in a most advanced scenario they advice to create two or three like Errors.resw, Messages.resw and that's about it. We have completely different approach (let's don't argue upon this, for us it proved to be good). We have a separate RESW file matching a CS file where we have resources which needs to be localized. We mimic the same folder structure in the Resource(language)\ folders as we have in the source code. The whole pattern came from Windows Phone Silverlight application and worked perfect with RESX. I have concerns regarding this in universal app. The problem is that even though a RESW file is located deep in the directory structure like
Res\it\Controls\Browser\MusicDetails.resw
it is referred as if it is located in the language root at Res\it. For example to get this resource in the code the code would look like this
resourceLoader = ResourceLoader.GetForCurrentView(currentAssemblyName + "/MusicDetails");
resourceLoader.GetString("Title");
Getting back to windows phone silverlight app the path in a similar case looks like "\Controls\Browser\MusicDetails.resw" and it is definitely not an issue for the RESX resources.
Is there something we are missing or it is a hard RESW limitation and all RESW files no matter where they are located in the directory structure are treated as if they are at the root of the language directory? I foresee a problem if in the future we have exactly the same RESW name in different directory branches. How to work around this?
I think is not possible to do that, I tried to do something like you before with Windows 8.1 and it was not possible now with UWP is the same we need follow the guidelines here
https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh965328.aspx
I did this steps and it works like a charm.
UWP apps have restrictions they are not like traditional apps (Win32 apps)
I am developing an MVC4 public facing website which should have a blog, I didn't want to develop one from scratch so I got a nice open source one from codeplex.
Herein lies the problem: I have to integrate this into the site I am building, I can't have a random link sending the user off to a separate blog site as I have to display sections from the blog on my original site.
I thought about using Areas which I will give a go after posting this but I was interested in knowing if there is a better way to do this or caveats that i need to be aware of etc.
Thanls for all the help :)
So I managed to do this with a bit of tinkering.
First I added the source code projects to my solution. Then I created an area called Blog and deleted all of the boilerplate stuff except BlogAreaRegistration.cs. I then looked at the References and referenced all corresponding libraries as well as the accompanying class library projects.
I copied all the folders except App_Data, Content and Scripts into Areas/Blog. Copied the previously mentioned folders to their respective locations in the root website.
I then compared both Global.asax's and web.configs, copied across the missing sections into my own files (not without the help of Examdiff for the configs).
I then had to copy the default ViewTemplates from the Areas/Blog/Views directory to the root Views Folder.
...press F5 and voila!
Ofcourse I make it sound like a disney fairytale bbut it was alot more difficult with lots of trial and error (of a yellow screen of death kind).
Well, that's my 2 cents just incase anyone else runs into the same murky waters in the future
I'm a first time poster long time listener and I would really be interested in reading about some of your localization architectures and, eventually, to get feedback on our approach (as follows).
I would like some advice on an approach we're thinking of using with resource files. We are using MVC 3.0 and have a website project and a resource project. In the resource project we have a structure which mimics the same structure as the website e.g. controller -> view -> file.
We reference the resx files in the views by importing the resource namespace on the top of the view/control e.g. <%# Import Namespace="MyAppResources.Resources.Website.Home" %> and then reference the resx value we need by using <%= Index.SomeText %> where index is the name of the resource file.
What we were thinking of doing and would love some advice is instead of using this approach is to divide the resource resx structure into website areas and use a helper e.g. LocalizationHelper.GetValue("Home", "SomeText") where "Home" is the name of the resource file and "SomeText" is a value in that resx file. The reason we would do this is not to have to keep compiling the resource project for every small copy change we make (as we may need a quick fix for our deployed environment) and also it will probably be the most commonly used helper in the website project so this would keep things short and consistent. The Localization helper would also store the values in a cached dictionary so if a value is used more than once it would retrieve it from the cache.
Does anyone know of a better approach or improvements we have not thought of?
I would recommend using a database to store the localized values instead of a RESX file.
Using a database would prevent you from needing to make any code/file deployments to update your application. Furthermore, you could build a GUI interface for modifying the localized values (which is a great feature for the site administrators/editors).
I would like to start using my own templates for iOS applications. I don't want any significant changes, but simpler things like
add/remove some boilerplate code
add some pragma mark sections
hardcode my company's name and some comments for every file
change the indentation
etc etc etc
The idea is that we will share these templates when we create apps, but at the same time we want to keep the default template files that Xcode 4 already provides. So, in the following screenshot, how can I add a "CompanyName Application" section that contains exactly the same templates (Navigation-based, View-based etc), but with my own changes?
I found that I can add a folder under /Developer/Library/Xcode/Templates/ or /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/ but I'm a bit confused with what do I need to do exactly. I would really appreciate it if you could help me with that, as I have already messed up my folders twice with no luck. Thanks!
This blog post by borealkiss has detailed instructions. For starters:
If you add your own templates, the place you should use is under the following path:
~/Library/Developer/Xcode/Templates/
The problem is that it is quite hard to create a custom template.
For example, to copy and paste the
built-in template to your place will
not show up the template on Xcode 4
until you manually change its
identifier in TemplateInfo.plist.
I just found this article from Bob McCune "Creating Custom Xcode 4 File Templates" that is exactly what I needed, so I put it here for reference.
I have an ASP.NET MVC2 application where I need to support not only multiple languages, but also potentially multiple versions of each language. I usually solve localization requirements by using resx files in the App_GlobalResources folder, and this works well as long as I do not need to support multiple resource-sets for the same language.
This is an issue because each customer shall be able to specify a set of resources, and they may use the same language.
My initial thought was to have a file structure where every customer has a separate folder located under for instance App_Data. In this customer folder I would put configuration files and resources. But then I would need a way to tell the application that it should look for resources in this particular folder instead of App_GlobalResources.
So my question is: Is this doable, and what do I have to do to make it work? Is this a bad way to solve a problem like this, and if that seems to be the case: Does anyone have suggestions for a better solution?
Will be thankful for all input.
I usually use a custom ResourceProviderFactory to store the resources in the database. Creating a custom provider to look in specific folders should not be to hard if you can distinguish the different customers by virtualpath.
But then I would need a way to tell the application that it should look for
resources in this particular folder instead of App_GlobalResources.
You might consider compiling your resources so that they are deployed as DLLs rather than compiled at runtime. To do this you have to move your resources our of the standard App_GlobalResources.
This post has a good explanation of the benefits of doing this:
http://odetocode.com/Blogs/scott/archive/2009/07/16/resource-files-and-asp-net-mvc-projects.aspx