翻译字符串AndroidStudio

时间:2015-11-16 19:53:43

标签: java android android-studio internationalization translate

我想翻译这段代码:

List.add("  Temperature: " + matrix[1][2] + " ºC");

我想翻译一下这个词"温度:"但我不知道如何把它放在Strings.xml上

编辑:我想知道如何在Strings.xml上添加Temperature然后进行翻译

1 个答案:

答案 0 :(得分:2)

要将其放在 calls_by_disability.each do |disability| pdf.text "#{disability}", style: :bold, color: "001133" header = ["Call ID", "Date", "County", "Service Category", "Service", "Notes"] table_data = [] table_data << header disability.calls.map do |call| table_data << [call.id, call.date, call.country, call.service_category, call_service, call.notes] end pdf.table(table_data) end 上,您必须添加以下内容:

Strings.xml

然后,如果您想在<string name="Temperature">Temperature: </string> 中使用它,请执行以下操作:

Strings.xml

要翻译它,您必须使用the suffix of the language code为该语言创建不同的值目录。

See the documents

编辑(参数字符串)

添加参数@trooper表示如下:

您的List.add(getString(R.string.Temperature) + matrice[1][2] + " ºC"); 应该是

Strings.xml

然后在你的java代码中你必须使用它:

<string name="Temperature">Temperature: %1$s ºC</string>