App name in Finder not matching app name in Terminal

半城伤御伤魂 提交于 2021-02-08 08:24:39

问题


It's shown as nwjs.app in Finder but nw-demo.app in Terminal.

If I rename the app using mv nw-demo.app nw-demo2.app, it shows correctly in Finder. If I then rename it back using mv nw-demo2.app nw-demo.app, it shows as nwjs.app again. Strange.

The name should be nw-demo.app, that's what I want, but it's nwjs.app. I don't see anything in nw-demo.app/Contents/Info.plist or anywhere that would set it to nwjs. Here's the Info.plist:


回答1:


All I had to do was delete nw-demo.app/Contents/Resources/*.lproj. Apparently those files are used for internationalization and affect the display name.




回答2:


If your Info.plist contains the CFBundleDisplayName key (shown as "Bundle display name" in your screenshot) and if its value matches the name of the app bundle on disk (minus the .app extension), then Launch Services searches the app bundle for a InfoPlist.strings file among the localizations matching the user's selected language(s). If it finds one and that has a localization for the CFBundleName key, then it uses that localization as the display name for the bundle.

The Finder, Dock, file dialogs, etc. all use the display name as obtained from Launch Services when presenting files and directories to the user.

The comparison of the Info.plist value to the name on disk is to allow users to rename app bundles however they like. If the user has renamed it, the strings won't match and there's no attempt to localize the user-supplied name. However, if the strings do match, that suggests the user hasn't renamed it (or has carefully renamed it back to the real original value, not the apparent original value), so the app-provided localization is respected.



来源:https://stackoverflow.com/questions/37890440/app-name-in-finder-not-matching-app-name-in-terminal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!