iOS Facebook SDK 本地化 [英] iOS Facebook SDK localization

查看:28
本文介绍了iOS Facebook SDK 本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改 FBLoginView 按钮中的文本,但到目前为止我还没有运气.我尝试从 FacebookSDK 阅读 README 并查看互联网.我在项目本地化部分添加了 2 种语言,它在支持文件中为每种语言创建了 2 个文件,但我尝试使用 README 的示例内容更改其中的字符串(更改字符串值),但即使我更改了英语文件我总是得到默认的登录字符串.然后我尝试添加一些 Bundle 设置并更改其中的一些文件,但也没有运气.有人可以告诉我如何逐步实现更改 facebook 字符串吗?谢谢

I am trying to change text in FBLoginView button but I have no luck so far. I've tried to read README from FacebookSDK and look at internet. I added 2 languages in project Localizations sections it creates 2 files in Supporting files for each language but I tried to change strings in there with example content of README (with changed string values) but even if I changed english file I always get default login string. Then I tried to add some Bundle settings and change some files in there but with no luck too. Can someone tell me how can I achieve change facebook strings step by step? Thanks

推荐答案

更新:

此处描述的方法不再适用于最新的 Facebook SDK.所以请参考@Erik van der Neut 或@Ted 给出的答案,并使用捆绑包FacebookSDKStrings.bundle 随 SDK 一起提供,用于字符串覆盖.

The method described here is no longer applicable for the latest Facebook SDKs. So please refer to the answers given by @Erik van der Neut or @Ted, and use the bundle FacebookSDKStrings.bundle that ships with the SDK for string overrides.

到目前为止,我发现本地化/更改 Facebook 字符串的唯一方法在他们的常见问题解答中进行了描述:https://developers.facebook.com/docs/ios/troubleshooting/

The only way I found so far to localize/change the Facebook strings is described in their FAQ: https://developers.facebook.com/docs/ios/troubleshooting/

我所做的是从 Facebook SDK 附带的 Scrumptious 示例项目中复制文件 FacebookSDKOverrides.bundle.这基本上只是一个包含(可以包含)不同本地化文件夹的包.如果要添加德语字符串,请在包中创建一个文件夹 de.lproj.此文件夹应包含一个文件 Localizable.strings.

What I did was to copy the file FacebookSDKOverrides.bundle from the Scrumptious sample project that ships with the Facebook SDK. This is basically just a package that contains (can contain) different localization folders. If you want to add German strings, create a folder de.lproj within the bundle. This folder should contain a file Localizable.strings.

您可以在文件 FacebookSDKResources.bundle.README 中找到所有可覆盖字符串的列表.您可以在 FacebookSDK 文件夹中找到它:

You can find a list of all overrideable strings in the file FacebookSDKResources.bundle.README. You can find it in the FacebookSDK folder:

FacebookSDK.framework/Resources/

或在这里:https://github.com/facebook/facebook-ios-sdk/blob/master/src/FacebookSDKResources.bundle.README

例如,要添加登录按钮文本的德语翻译,您必须将以下内容添加到 de.lproj 中的文件 Localizable.strings 中:

To add a German translation of the text of the login button, for example, you have to add the following to the file Localizable.strings in de.lproj:

"FBLV:LogInButton" = "Einloggen";

作为最后一步,您必须确保 Facebook 知道该捆绑包.因此,您可以将以下内容添加到您的 Info.plist:

As a last step, you have to make sure that Facebook knows about the bundle. Therefore, you can add the following to your Info.plist:

<key>FacebookBundleName</key>
<string>FacebookSDKOverrides</string> 

或者,如果您愿意,也可以在代码中指定:

Alternatively, you can also specify this in code if you want to:

[FBSettings setResourceBundleName:@"FacebookSDKOverrides"];

这对我有用,虽然我想使用我的主包进行覆盖,并在我的正常应用程序翻译中指定它们.这对于连接翻译工具会更方便,因为您不需要为每种语言翻译多个文件.

This worked for me, although I would like to use my main bundle for overrides and just specify them in my normal app translations. This would come in more handy for the connection to translation tools as you don't need to translate multiple files per language.

这篇关于iOS Facebook SDK 本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆