mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-24 22:45:19 +00:00
Add base localization infrastructure and externalize strings (#670)
* Add base localization infrastructure and externalize strings * Add Spanish localization scaffolding with translations * Add machine translations for expanded locales --------- Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension
|
||||
|
||||
Base English strings for the share extension.
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "nothing to share";
|
||||
"share.status.no_shareable_content" = "no shareable content";
|
||||
"share.fallback.shared_link_title" = "shared Link";
|
||||
"share.status.shared_link" = "✓ shared link to bitchat";
|
||||
"share.status.shared_text" = "✓ shared text to bitchat";
|
||||
"share.status.failed_to_encode" = "failed to encode link";
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (Arabic)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "لا شيء لمشاركته";
|
||||
"share.status.no_shareable_content" = "لا محتوى قابلاً للمشاركة";
|
||||
"share.fallback.shared_link_title" = "رابط مشترك";
|
||||
"share.status.shared_link" = "✓ تم إرسال الرابط إلى bitchat";
|
||||
"share.status.shared_text" = "✓ تم إرسال النص إلى bitchat";
|
||||
"share.status.failed_to_encode" = "تعذر ترميز الرابط";
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (German)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "nichts zum teilen";
|
||||
"share.status.no_shareable_content" = "kein teilbarer inhalt";
|
||||
"share.fallback.shared_link_title" = "geteilter link";
|
||||
"share.status.shared_link" = "✓ link zu bitchat geteilt";
|
||||
"share.status.shared_text" = "✓ text zu bitchat geteilt";
|
||||
"share.status.failed_to_encode" = "link konnte nicht codiert werden";
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (Spanish)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "nada que compartir";
|
||||
"share.status.no_shareable_content" = "sin contenido que se pueda compartir";
|
||||
"share.fallback.shared_link_title" = "enlace compartido";
|
||||
"share.status.shared_link" = "✓ enlace compartido con bitchat";
|
||||
"share.status.shared_text" = "✓ texto compartido con bitchat";
|
||||
"share.status.failed_to_encode" = "no se pudo codificar el enlace";
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (French)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "rien à partager";
|
||||
"share.status.no_shareable_content" = "aucun contenu partageable";
|
||||
"share.fallback.shared_link_title" = "lien partagé";
|
||||
"share.status.shared_link" = "✓ lien partagé vers bitchat";
|
||||
"share.status.shared_text" = "✓ texte partagé vers bitchat";
|
||||
"share.status.failed_to_encode" = "échec de l'encodage du lien";
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (Hebrew)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "אין מה לשתף";
|
||||
"share.status.no_shareable_content" = "אין תוכן שניתן לשתף";
|
||||
"share.fallback.shared_link_title" = "קישור משותף";
|
||||
"share.status.shared_link" = "✓ הקישור נשלח אל bitchat";
|
||||
"share.status.shared_text" = "✓ הטקסט נשלח אל bitchat";
|
||||
"share.status.failed_to_encode" = "לא ניתן לקודד את הקישור";
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (Indonesian)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "tidak ada yang bisa dibagikan";
|
||||
"share.status.no_shareable_content" = "tidak ada konten yang bisa dibagikan";
|
||||
"share.fallback.shared_link_title" = "tautan dibagikan";
|
||||
"share.status.shared_link" = "✓ tautan dikirim ke bitchat";
|
||||
"share.status.shared_text" = "✓ teks dikirim ke bitchat";
|
||||
"share.status.failed_to_encode" = "gagal mengodekan tautan";
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (Italian)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "niente da condividere";
|
||||
"share.status.no_shareable_content" = "nessun contenuto condivisibile";
|
||||
"share.fallback.shared_link_title" = "link condiviso";
|
||||
"share.status.shared_link" = "✓ link inviato a bitchat";
|
||||
"share.status.shared_text" = "✓ testo inviato a bitchat";
|
||||
"share.status.failed_to_encode" = "impossibile codificare il link";
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (Japanese)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "共有できるものがありません";
|
||||
"share.status.no_shareable_content" = "共有可能なコンテンツがありません";
|
||||
"share.fallback.shared_link_title" = "共有リンク";
|
||||
"share.status.shared_link" = "✓ bitchatにリンクを共有";
|
||||
"share.status.shared_text" = "✓ bitchatにテキストを共有";
|
||||
"share.status.failed_to_encode" = "リンクのエンコードに失敗しました";
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (Nepali)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "बाँड्ने केही छैन";
|
||||
"share.status.no_shareable_content" = "बाँड्न मिल्ने सामग्री छैन";
|
||||
"share.fallback.shared_link_title" = "साझा गरिएको लिङ्क";
|
||||
"share.status.shared_link" = "✓ bitchat मा लिङ्क पठाइयो";
|
||||
"share.status.shared_text" = "✓ bitchat मा पाठ पठाइयो";
|
||||
"share.status.failed_to_encode" = "लिङ्क सङ्केत गर्न सकेन";
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (Portuguese - Brazil)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "nada para compartilhar";
|
||||
"share.status.no_shareable_content" = "nenhum conteúdo compartilhável";
|
||||
"share.fallback.shared_link_title" = "link compartilhado";
|
||||
"share.status.shared_link" = "✓ link enviado para bitchat";
|
||||
"share.status.shared_text" = "✓ texto enviado para bitchat";
|
||||
"share.status.failed_to_encode" = "falha ao codificar link";
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (Russian)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "нечем поделиться";
|
||||
"share.status.no_shareable_content" = "нет подходящего контента";
|
||||
"share.fallback.shared_link_title" = "поделился ссылкой";
|
||||
"share.status.shared_link" = "✓ ссылка отправлена в bitchat";
|
||||
"share.status.shared_text" = "✓ текст отправлен в bitchat";
|
||||
"share.status.failed_to_encode" = "не удалось закодировать ссылку";
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (Ukrainian)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "нема чим ділитися";
|
||||
"share.status.no_shareable_content" = "нема відповідного контенту";
|
||||
"share.fallback.shared_link_title" = "спільне посилання";
|
||||
"share.status.shared_link" = "✓ посилання надіслано в bitchat";
|
||||
"share.status.shared_text" = "✓ текст надіслано в bitchat";
|
||||
"share.status.failed_to_encode" = "не вдалося закодувати посилання";
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
bitchatShareExtension (Simplified Chinese)
|
||||
*/
|
||||
|
||||
"share.status.nothing_to_share" = "没有可分享的内容";
|
||||
"share.status.no_shareable_content" = "没有可分享的素材";
|
||||
"share.fallback.shared_link_title" = "分享的链接";
|
||||
"share.status.shared_link" = "✓ 已将链接分享至 bitchat";
|
||||
"share.status.shared_text" = "✓ 已将文本分享至 bitchat";
|
||||
"share.status.failed_to_encode" = "无法编码链接";
|
||||
@@ -14,6 +14,15 @@ import UniformTypeIdentifiers
|
||||
final class ShareViewController: UIViewController {
|
||||
// Bundle.main.bundleIdentifier would get the extension's bundleID
|
||||
private static let groupID = "group.chat.bitchat"
|
||||
|
||||
private enum Strings {
|
||||
static let nothingToShare = NSLocalizedString("share.status.nothing_to_share", comment: "Shown when the share extension receives no content")
|
||||
static let noShareableContent = NSLocalizedString("share.status.no_shareable_content", comment: "Shown when provided content cannot be shared")
|
||||
static let sharedLinkTitleFallback = NSLocalizedString("share.fallback.shared_link_title", comment: "Fallback title when saving a shared link")
|
||||
static let sharedLinkConfirmation = NSLocalizedString("share.status.shared_link", comment: "Confirmation after successfully sharing a link")
|
||||
static let sharedTextConfirmation = NSLocalizedString("share.status.shared_text", comment: "Confirmation after successfully sharing text")
|
||||
static let failedToEncode = NSLocalizedString("share.status.failed_to_encode", comment: "Shown when the share payload cannot be encoded")
|
||||
}
|
||||
|
||||
private let statusLabel: UILabel = {
|
||||
let l = UILabel()
|
||||
@@ -44,7 +53,7 @@ final class ShareViewController: UIViewController {
|
||||
private func processShare() {
|
||||
guard let ctx = self.extensionContext,
|
||||
let item = ctx.inputItems.first as? NSExtensionItem else {
|
||||
finishWithMessage("Nothing to share")
|
||||
finishWithMessage(Strings.nothingToShare)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -61,7 +70,7 @@ final class ShareViewController: UIViewController {
|
||||
if let title = item.attributedTitle?.string, !title.isEmpty {
|
||||
saveAndFinish(text: title)
|
||||
} else {
|
||||
finishWithMessage("No shareable content")
|
||||
finishWithMessage(Strings.noShareableContent)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -81,7 +90,7 @@ final class ShareViewController: UIViewController {
|
||||
self.saveAndFinish(text: t)
|
||||
}
|
||||
} else {
|
||||
self.finishWithMessage("No shareable content")
|
||||
self.finishWithMessage(Strings.noShareableContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,20 +145,20 @@ final class ShareViewController: UIViewController {
|
||||
private func saveAndFinish(url: URL, title: String?) {
|
||||
let payload: [String: String] = [
|
||||
"url": url.absoluteString,
|
||||
"title": title ?? url.host ?? "Shared Link"
|
||||
"title": title ?? url.host ?? Strings.sharedLinkTitleFallback
|
||||
]
|
||||
if let json = try? JSONSerialization.data(withJSONObject: payload),
|
||||
let s = String(data: json, encoding: .utf8) {
|
||||
saveToSharedDefaults(content: s, type: "url")
|
||||
finishWithMessage("✓ Shared link to bitchat")
|
||||
finishWithMessage(Strings.sharedLinkConfirmation)
|
||||
} else {
|
||||
finishWithMessage("Failed to encode link")
|
||||
finishWithMessage(Strings.failedToEncode)
|
||||
}
|
||||
}
|
||||
|
||||
private func saveAndFinish(text: String) {
|
||||
saveToSharedDefaults(content: text, type: "text")
|
||||
finishWithMessage("✓ Shared text to bitchat")
|
||||
finishWithMessage(Strings.sharedTextConfirmation)
|
||||
}
|
||||
|
||||
private func saveToSharedDefaults(content: String, type: String) {
|
||||
|
||||
Reference in New Issue
Block a user