macos:Resouce-management
出自UXGuide.net
请帮助我们修订和更新本文的中文部分
本文的中文部分虽然取自官方最新中文版本,但与英文原版相比已落后了一年多,可能无法反映英文版本中最近的修改,且文中笔误、前后译法矛盾、未翻译完全的片断较多,请您帮助一起修订完善。详情参见中文版修订完善计划。
资源管理
Resource Management
Application bundles simplify installation and are easy for the user to move around in the Finder. Application bundles are the preferred mechanism for software distribution. Here are some tips to help you manage your application bundle’s resource files:
程序包简化了程序的安装,并且可以很容易在Finder中移动。程序包是推荐的软件发布机制。下面是能够帮助您管理您程序包中资源文件的一些技巧:
- Include all required resources inside your application bundle. Your application bundle should always have everything it needs in order to run.
- 在程序包中包含所有的资源文件以及程序运行必须的所有文件。
- Include only the specific subset of files that require localization in your application bundle’s language-specific resource directories. If a resource does not require localization, there is no need to create extra copies of it. The bundle-loading code checks for global resources as well as localized resources and returns the one that is most appropriate.
- 在程序包特定语言资源的目录中仅包含需要本地化的文件。如果资源不需要被本地化,则无须为它创建额外的拷贝。程序包加载的代码会同时检查本地资源和全局资源并返回最合适的资源。
- Use an installer to place optional resources in the appropriate
Librarysubdirectory of the user’s system. Optional resources are things like document templates or other resources that are useful to an application but not required for it to launch. Most application-related files should go in an application-specific subdirectory of~/Library/Application Supportor/Library/Application Support. See File System Overview for information on where to install files.
- 使用安装器来将一些可选的资源文件放在用户系统中合适的
Library子目录下。可选的资源文件是那些如文档模板等对程序有用但是不是启动程序必须的资源文件。大部分和程序相关的文件应该在~/Library/Application Support或者/Library/Application Support的相应程序的子目录中。关于安装文件的位置的更多信息,请参考文件系统概述。
- Avoid storing data in the resource fork of your application executable. Resource forks are not an appropriate way to store application-related resources. Instead, store your resources as individual files inside your application bundle. See Bundle Programming Guide for more information on where resources belong in the bundle structure.
- 避免将资源保存在程序的可执行文件的资源段中。资源段并不是保存程序相关的资源的合适的位置,您应该将资源文件保存成程序包中独立的文件。关于资源文件在程序包中的结构的更多信息,请参考包编程指南。