This is not a question about standard localization - I know how to localize the app, use resources, Uid's and so on - this works perfectly.
The problem is that the app comes within a bundle, therefore when the user installs the app it covers only languages that are selected in device/phone settings. But I would like to provide an option in settings that would allow choosing a language regarding the settings. For this purpose, I can use ApplicationLanguages.PrimaryLanguageOverride, which works very nice when deployed via VS, but as I've mentioned - version from the store lacks resources, as not all are installed.
Does anybody know how to bypass this bundle behavior?
The problem is also that I'm using MAT (multilingual app toolkit) and my translation comes with xliff files. I've spent quite a lot of time to find a way to convert them to resw files, without success. Is there any way to do it (or I've to write my own converter)?
You need to use ResourceContext:
var context = new ResourceContext(); // deliberately not using getForCurrentView()
context.Languages = new string() {"fr-fr"};
ResourceMap resourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("Resources");
String str = resourceMap.GetValue("string1", context).ValueAsString;
More info at:
'How to load string resources' and
'ResourceContext class'ResourceContext class'.
PS. I have app in store and there is no problem with changing language without reinstall so all resources must be there
Check out this: UWP: Resource file for languages is not deployed correctly you need to get rid of bundle in order for my code from above to work. Or you could check if chosen language is installed in OS and if not you could not allow user to choose it using:
Windows.System.UserProfile.GlobalizationPreferences.Languages
Related
I am having a problem where my app translations work on my pc when I set different language with ApplicationLanguages.PrimaryLanguageOverride, but after the same app is uploaded into Microsoft Store and downloaded from there - translations stop working. As a default it uses English language and ignores other selected languages.
Any idea why?
If you are generating an app bundle during Store package creation, the language-specific resources, different image scaling options, etc. are exported to separate packages to minimize the app package size that has to be downloaded by the user. This however means, that the system will download only the languages it deems required. So if you don't add the target language in the list in the Region & Language area of system settings, it won't probably be downloaded as part of the app package and hence switching to it manually using PrimaryLanguageOverride will have no effect. However note that when you add the language, the system will later download the language-specific resources automatically from the Store, so it will then be available.
I would like to build a simple .NET application that installs on a windows machine which will allow the end user to open a command prompt and type "google test" which will open google and search for test. But I'm not sure how to install a global "keyword" such as "google". Is this down via Environment variables? How does this link up to my .NET application?
Any advice or pointers is appreciated.
Thanks
This is beyond a .NET application and belongs into the Area of Setup programms. Visual Studio used to have a Installer Project, but as there are so many 3rd party ways this was removed.
Having "google test" parsed as a google search for "test" is tricky, but possible. However it depends entirely on how the commandline is parsed in a Windows. Wich is pretty much the way it was parsed since DOS 1.0.
If you just enter a word like "google", the commandline will look if there is a Excetuable file (.exe, .com, .bat) of that name in the current folder (working directory). It will then look into all the folders defined in the path variables. However using path variables is so dated, I could find only a single entry in my Windows Path variable now. And it is for MS backward compatibility: "%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;"
Most starting of programms is done via file associations with a specific type. And protocoll associations with a protocoll (like http, https, steam). Indeed my advise would be to make a .NET Programm named "google" whose sole purpose is to to format the proper URL, then send it to console parsing via ProcessStart. And let Windows solve wich programm to use from there.
Edit: And as I only realized after wirting this, apparently Windwos finally supports commandline aliases. https://learn.microsoft.com/en-us/windows/console/console-aliases
Apparently they even added a way to make them via the WinAPI in Windows 2000. However that requires moving to unmanaged code. And I have no experience, but it appears those aliases might only be valid for one console instance. So you might have to put it into a place like hte autoexec.bat to be called everytime a console is created.
I developed an ASP.NET web site. When viewing the application in the browser the version number is shown in the footer of the application. But I want to communicate the version number with the customer even if the appliction is not running.
Is it good to use a post build event for it to write it into a text file? If so, how can I access the version number (there is no predefined variable for this) and how can I write it into a text file via the command-line?
Are there any other, maybe simpler ways of getting this done?
Thanks for you help.
Edit: What I forgot to say is that it should be included when publishing the project using the Publish dialog.
You could use a build tool such as msbuild and nant to control the build number and update a application setting in the web.config.
or you can use some reflection code to retrieve it
Assembly web = Assembly.Load("App_Code");
AssemblyName webName = web.GetName();
string myVersion = webName.Version.ToString();
preferably store the string in cache
I'm using SharpDevelop to create a WinForm-based C# application. After studying my target audience, I believe it is in my best interest to use a no-install application. While creating my HelloWorld! program to get to know SharpDevelop (I have just switched from VBExpress), I found that the file it outputs is a .exe without any setup process. However, I'm worried that some of the features I want won't be compatible with this format. I don't want to get deep into this app and find out users are going to have to keep the program in the same directory as 548 other random files.
Here are the features I'm concerned about:
+Save user data (XML) in AppData.
+Access internet feeds (XML and/or JSON).
+Minimize to tray on close.
Also, are there any common pitfalls with this type of deployment method?
EDIT: I understand the enduser will need the .NET framwork for C# programs. I am not worried about this.
It will execute with the same privileges.
The only thing you will want to look out for is making sure the end user has the correct .NET framework installed since you don't have an installer to do that for you. But now reading the end of your message it appears you already have that covered.
If you are concerned about the deployment technique you can test it on a non-dev machine, though the results should be the exact same.
for extracting special folder icons I'm using
ExtractIconEx(Environment.SystemDirectory + "\\shell32.dll",ncIconIndex, handlesIconLarge, handlesIconSmall, 1);
Here im passing explicitly nIconIndex for special folders like MyDocs,MyPictures ..etc
and its working fine in XP ,however in Vista its not retrieving the correct icons ..there it retrieves yellow folder icons..it should not be the case.
Cn anybody help me on this..
Vista added a new API called SHGetStockIconInfo but it does not support my documents AFAIK. But that does not matter since the method you SHOULD be using works on both XP and Vista (Your current solution will not work when the user has selected a custom icon, you are just looking in hardcoded system dlls, this could change at any point)
So, what you should do is, get the path or PIDL to the shell folder you are interested in (SHGetFolderPath and friends) and pass that path/PIDL to SHGetFileInfo. SHGetFileInfo can give you a icon handle, or the index into the system image list.
I'm not sure what the .NET equivalent for those functions are, but you should be able to figure that out, or use PInvoke
Check out the IconLib library at codeproject.
The best example I've seen of success in this area from .NET (and it was done with VB.NET) is in this article.
http://www.codeproject.com/KB/cpp/VbNetExpTree.aspx
My $.02 is that working with the shell API is extremely painful from .NET due to the level of COM interop required and the complexity of the API's.