Implementation of new package with multi language - cocoa

I am implementing one mac application.Its window version is already implemented.Now i am facing the following issue:
Implementation of new package with multi language (user could choose the language of the application while installing the app). ie For the windows version of the software, when executing the installation file user could choose the language in which the application should be installed. I want this feature to included in the mac version. ie the while installing the app using the package created the user should be able to choose the language of installation.(Currently in the mac version multilanguage is implemented using NSLocalizedString so that the app displays language according to the machine language and the installation package is localized). But i specifically want the users to be able to choose the installation language of the app, while installing.Pls help to solve this issue….

Use NSString *locString = NSLocalizedStringFromTable(#"key", #"Japanese", #"comment for key"); instead ;)
Explanation:
If you look at NSLocalizedString macro definition you will find that it actually calls -[NSBundle localizedStringForKey:value:table:] method in which the last parameter is the localization file (ie: Localizable.strings). You can get available localizations with-[NSBundle localizations]; method.
This means that you could use it to directly access a localization file like this:
// This gets the localized string found in Japanese.strings for the key #"key"
NSString *locString = [thisBundle localizedStringForKey:#"key"
value:#"No translation"
table:#"Japanese"];
Or use the macro (Which is almost equivalent)
NSString *locString = NSLocalizedStringFromTable(#"key", #"Japanese", #"comment for key");
The difference is what happens when the given key is not available:
the former returns #"No translation"
the latter returns the default localization for #"key"
Please see NSBundle class reference for more details
Hope it helps

Related

Is there a macOS objective c or swift call for me to check if a system extension has been installed?

I have googled and searched here and have come up empty.
I have an application that installs a system extension and I'm resorting to writing to a file when the extension is installed to know.
Is there an objective C or Swift function that does essentially what systemextensionctl list does? This is a sandboxed app and I don't want to (and suspect I can't) fork/run a shell command.
There is still no public API to do that, but there is a way to use the private API under the systemextensionctl, OSSystemExtensionClient, as described here.
You will need to reverse the OSSystemExtensionClient futher to get the list of extensions.
It also may be that you can find desired information in some .db files.
Both things are not considered as public and could be changed at any moment.

Using i18n with RequireJS in Visual Studio 2015 Cordova App project

I got a weird thing happening when I try to run the Windows application produced by the Cordova project in Visual Studio 2015.
The application uses the third-party libs i18n along with RequireJS to translate any text based on the language chosen by the user. The problem is that no text is loaded without any form of error or whatsoever. The same exact code works for Android and iOS builds just fine.
I went into debug to find out something weird, whatever language I submit will return the value undefined. Even weirder, if I require specifically the root file manually, it will load the english version of the file.
Any help would be appreciated.
Here's a sample project that mimics the exact problem.
CordovaTest.rar
The issue you're running into with Windows is its support of qualifiers in file names to support localization.
Resource qualifiers are folder and filename modifiers that identify
the context in which a particular version of a resource should be
used.
Contexts can include locales which is what you've run into here. Long story short, here's what it looks like is happening:
Your app's default language is set to "fr" right now
When the app starts on Windows, it sees that you're running as the "fr" local and it hides any folders qualified as targeting other locales. In this case, your app has an "en" folder that is seen as a qualifier for the English language, and Windows will hide the "en" folder contents.
It's really hard to explain the first time around, so let me know if you want clarification on the above and I can try to re-phrase it.
To fix your issue, you would want to use folder names that are not seen by Windows as qualifiers. For example, you could name your "en" folder and call it "English". Then, change your RequireJS bundle configuration to define the "english" locale:
define({
"root": {
"Test" : "TestFR"
},
"english":true
});
Now when you run your app, you'll see it working.

Equivalent of system.Reflection.Assembly.GetExecutingAssembly().FullName

At the moment I am porting an Windows phone Silverlight application to windows mobile using the UWP Platform.
In my old code I used a function to get the ExecutingAssemblyName in the following way:
public static string ExecutingAssemblyName {
get {
string name = System.Reflection.Assembly.GetExecutingAssembly().FullName;
return name.Substring(0, name.IndexOf(','));
}
}
now I want to get the same result in Windows mobile but the functions described in the following link do not all seem to be there in Windows mobile.. The only ones I can find are :
System.Reflection.Assembly.equals
System.Reflection.Assembly.load
System.Reflection.Assembly.ReferenceEquals
Does anybody now how to get the same result? Or should I start rewriting a lot of code.
Thank you already
To get the full name of an assembly, you can use the code as following (as Romasz mentioned).
this.GetType().GetTypeInfo().Assembly.FullName
In UWP, all of the app submitted to the store will be complied with .NET Native.
The .NET Native runtime doesn't include a JIT compiler. As a result,
all necessary native code must be generated in advance. A set of
heuristics is used to determine what code should be generated, but
these heuristics cannot cover all possible metaprogramming scenarios.
For more information, please refer the article Reflection and .NET Native.
In your case, I suggest you using the resource file (Resources.resw) to manage the text resource and put the file resources (like images, icons) under the Assets folder.

How to access a packaged CLI tool using Swift on OSX

I need to accomplish following three things. I am not sure how to go about it using Swift and Xcode
Package an existing CLI tool with the APP.
Use swift to issue commands to this CLI app and let it do its thing.
Read the output stream coming from the CLI app in real-time if possible.
I have found NSTask that should be utilized, but I get App Previlege Issues and errors. SMJobBless sounds helpful but I am having hard time to understand all this. All I was trying to do was issuing some commands to a cli app that is already embedded within my app package.
If you are looking to package a Command Line Tool you already wrote and have it run as root, that it is possible to do by installing it with SMJobBless but it's going to involve a bit of work. When installing a Command Line Tool in this manner, Apple refers to it as a helper tool. (Sometimes a privileged helper tool.)
For SMJobBless to succeed, Apple requires the following:
Your app must be signed.
The helper tool must be signed.
The helper tool must be located in the Contents/Library/LaunchServices directory inside your app's bundle.
The filename of the helper tool should be reverse-DNS format.
If your app has the bundle identifier "com.example.YourApp" then your helper tool may have a
filename of "com.example.YourApp.helper".
The helper tool must have an embedded launchd property list.
The helper tool's embedded launchd property list must have an entry with Label as the key and the value
must be the filename of the helper tool.
The helper tool must have an embedded info property list.
The helper tool's embedded info property list must have an entry with
SMAuthorizedClients
as its key and its value must be an array of strings. Each string must be a
code signing requirement.
Your app must satisify at least one of these requirements.
Only processes which meet one or more of these requirements may install or update the helper tool.
These requirements are only about which processes may install or update the helper tool. They impose no
restrictions on which processes can communicate with the helper tool.
The helper tool's embedded info property list must have an entry with
CFBundleVersion
as its key and its value must be a string matching the format described in CFBundleVersion's documentation.
This requirement is not documented by Apple, but is enforced.
While not documented by Apple, SMJobBless will not overwrite an existing installation of a helper tool with one
that has an equal or lower value for its CFBundleVersion entry.
Your app's Info.plist must have an entry with
SMPrivilegedExecutables
as its key and its value must be a dictionary. Each dictionary key must be a helper tool's filename; for example
"com.example.YourApp.helper". Each dictionary value must be a string representation of a code
signing requirement that the helper tool satisfies.
If you want to see a sample project that is configured to satisfy these requirements, you can take a look at SwiftAuthorizationSample.

Air Native Extension for Mac - "does not have a method named"

I'm adapting an air extension for PC to the Mac. Successfully creating a project
which "ought to" work, but instead I get
Error #3500: The extension context does not have a method named
The packaged ANE is being loaded successfully, but no calls work. I suspect
that the initializer is not being called (and nothing is complaining about it).
My evidence being that I removed the initializer and finalizer from the C project
and the behavior did not change.
Any suggestions?
Versions: Xcode 3, Air-15, Flex 4.13, Flash Builder 4.7
Edit: more information; I discovered that exporting the application as a release build/signed native installer, then installing and running the application, it works
(well, still needs debugging, but the extension methods are being reached). So the
question simplifies to "what is wrong with the flash builder environment"
It is apparently impossible to use flash builder in conjunction with air native extensions on OSX.
Creating the extension context works without complaint, but calling any of the functions provided
results in "error #3500: The extension context does not have a method named ..."
It cost me a lot of time (and therefore my company's money) to discover that the ANE is actually fine, and can be
invoked outside of flash builder, by an appropriate command line, or by packaging a release executable.
This total package of behavior is very unsatisfactory, and has been known about for at least two years.
Even with the workaround (release packaging, or invoking using a command line) the workflow is
severely degraded.
--
for reference, the most helpful explanation of the workaround is at this URL
http://riawanderer.com/2012/03/27/working-with-air-native-extensions-on-the-mac/ note the date of this post!
then search for the panel that follows the text
"Now that simple demo code is ready, let’s run and see what does it do. When you run the app you should see below error indicating that Flex Builder Bug exists :)."

Resources