Skip to main content

Posts

Showing posts with the label resouce

Where we can add resjson files in a Metro Application

In one of my latest post I wrote a short introduction about how we can support localization in a Metro Application for Windows 8. The current framework for Metro Application makes a great job. Today I want to discuss about resjson files. This new extension was introduce with Metro Applications and help us to store all the strings that are localized in a very simple format (key, value) using json. In this case json is better than XML (when json is not better). By default, when we create a Metro Application, a folder named strings is created in the root of our project. Under this folder we can create us many folders we want with a name convention [cultureName]-[regionName]. string en-US Resources.resjson Error. resjson payPage. resjson en Resources. resjson Error. resjson payPage. resjson fe-BE Resources. resjson Error. resjson payPage. resjson I have the following question for you: How many strings fold...

How to load a resouce dynamic

Mai mult ca sigur cu toti am folosit fisiere cu resurse (*.resx). Folosirea lor nu implica nici o problema, totul este destul de simplu, dar uneori apare nevoie sa accesam o resursa in mod dinamic. De exemplu daca avem fisierul de resurse "CarResources.resx" si vrem sa accesam resursa 'Power' avem nevoie de urmatorul cod: string powerLabel = CarResources.Power; Dar apare urmatoarea problema, daca resursa de care avem nevoie o putem determina doar la runtime? O solutie ar fi sa folosim ResourcesManager , care ne permite sa incarcam o anumita resursa in mod dinamic. Exemplul de mai sus ar trebuii rescris in felul urmator: var carResource = new ResourceManager("CarResource",Assembly.GetExecutingAssembly()); var powerLabel = carResource.GetString("Power"); Trebuie avut grija din ce assembly incarcati resursa.