翻译

网站翻译 (Strings)

文本由 Phrase Language AI 从英语机器翻译而得。

用于 Strings 的 Play 框架

Play 框架 是一个适用于 Java 和 Scala 的高速 Web 框架。

准备应用程序

确保本地化文件格式正确,并且 Play 属性使用 UTF-8 编码。

要准备应用程序,请遵循以下步骤:

  1. 将所需的语言添加到 application.conf<1> 中,并按区域顺序降序设置优先级(en 最重要,de 次之,依此类推):

    application.langs="en,de,fr"
  2. messages.enmessages.demessages.fr 文件添加到 conf/ 文件夹中。

示例:

# 我的软件项目 (描述)
project.name=Some Name
title1=AwesomeApp

# 标题永远不嫌多!
more_titles=另一个标题

用于 Strings 的 Ruby i18n Rails 框架

要使用 Rails 进行 Ruby i18n,请遵循以下步骤:

  1. 下载最新的 客户 并遵循 设置说明

  2. 要初始化项目配置,请遵循说明

    $ phrase init

    遵循以下步骤来配置项目的原文/源语和目标语言。选择 .yml 作为区域文件格式。

  3. 如果现有的本地化文件存储在 ./config/locales 的默认位置,请使用 push 命令上传数据:

    $ phrase push

    在原文/源语路径中找到的所有现有本地化文件都会上传到项目。现有翻译现已在 Phrase 中,可以添加新的语言或键。

  4. 使用 pull 命令将已完成的翻译下载回项目:

    $ phrase pull

可选项

  • 添加自定义区域下载目录到 i18n 加载路径

    如果将本地化文件下载到 ./config/locales 以外的文件夹,请配置应用程序的 i18n 加载路径,以便可以访问新的本地化文件。

    打开 application.rbdevelopment/staging/production.rb 并添加配置(假设本地化文件已下载到 ./custom/locales。):

    config.i18n.load_path += Dir[Rails.root.join('custom', 'locales', '**', '*.yml').to_s]group :staging, :development do
      gem 'phraseapp-ruby'
    end

    重启应用程序后,新下载的文件即可见。

  • 安装 phraseapp-ruby gem

    如果使用 API 编写自定义工作流,请使用 phraseapp-ruby gem。

    通过将 phraseapp-ruby gem 添加到 Gemfile 中,将其添加到您的应用程序:

    group :staging, :development do
      gem 'phraseapp-ruby'
    end

    使用 bundle 命令安装它:

    $ bundle install

Strings 中的 Ruby Motion

RubyMotion 是一套用于 iOS、OS X 和 Android 开发的工具链,可以使用 Ruby 创建 iPhone、iPad、Mac 和 Android 应用程序。

phraseapp-rubymotion gem 连接 RubyMotion 应用程序,以从 国际化工作流 (iOS) 项目中受益。

安装 Gem

要安装该 gem,请按照以下步骤操作:

  1. 使用 bundler 将 phraseapp-rubymotion gem 添加到您的项目:

    gem 'phraseapp-rubymotion'

    或手动:

    $ gem install phraseapp-rubymotion
  2. 在 Rakefile 中引入该 gem。

初始化项目

将访问令牌和项目 ID 添加到应用程序的 Rakefile 中:

Motion::Project::App.setup do |app|
  app.name = \"Test Application\"
  app.development do
    app.phraseapp do
      app.phraseapp.enabled = true
      app.phraseapp.access_token = "YOUR_ACCESS_TOKEN"
      app.phraseapp.project_id = "YOUR_PROJECT_ID"
    end
  end
end

项目的项目 ID 可以在项目设置中找到。

用法

使用 phraseapp-rubymotion gem 可以通过 API 自动发送新的翻译,而无需将它们写入 Localizable.Strings 文件或进行上传。

本地化 Strings

通过使用其本地化对应项扩展所有字符串来本地化它们。在每个由 phraseapp-rubymotion 实现的字符串上调用 #__ 方法

"Hello World"

变为:

"Hello World".__

或者在使用回退翻译时:

"Hello World".__(\"My fallback translation\")

也可以使用通用键名称:

"HOME_WELCOME_BUTTON_LABEL".__
API 通信

构建并运行应用程序(在模拟器中)。在开发模式下,phraseapp-rubymotion 会自动发送所有本地化的 Strings,并将其视为新创建的键。如果本地化文件放置正确,翻译也会被传输。

当翻译完成时,将其与应用程序打包。所有翻译都可以通过 API 获取,并使用命令行客户存储在 RubyMotion 项目中。

要获取翻译,请按照以下步骤操作:

  1. 安装命令行客户 (CLI)。

  2. 为项目配置 CLI:

    $ phrase init

    完成配置项目源和目标的必要步骤。选择 Strings 作为区域文件格式。

  3. 下载本地文件。

    一旦翻译完成,使用 pull 命令将数据下载回项目:

    $ phrase pull

    要将所有现有的本地文件上传到项目:

    $ phrase push
这篇文章有帮助吗?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question, submit a request to our Support team.
Thank you for your feedback.