forked from nextcloud/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalizationResourceTest.kt
More file actions
178 lines (168 loc) · 6.47 KB
/
LocalizationResourceTest.kt
File metadata and controls
178 lines (168 loc) · 6.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2025 TSI-mc <surinder.kumar@t-systems.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
package com.nmc.android
import android.content.Context
import android.content.res.Configuration
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.owncloud.android.R
import junit.framework.TestCase.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import java.util.Locale
/**
* Test class to verify the strings customized in this branch PR for NMC
*/
@RunWith(AndroidJUnit4::class)
class LocalizationResourceTest {
private val baseContext = ApplicationProvider.getApplicationContext<Context>()
private val localizedStringMap = mapOf(
R.string.about_version to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to $$"Version %1$s",
Locale.GERMAN to $$"Version %1$s"
)
),
R.string.actionbar_see_details to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Share",
Locale.GERMAN to "Teilen"
)
),
R.string.drawer_item_on_device to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Offline files",
Locale.GERMAN to "Offline verfügbare Dateien"
)
),
R.string.prefs_lock to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Security",
Locale.GERMAN to "Sicherheit"
)
),
R.string.filedetails_download to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Offline availability",
Locale.GERMAN to "Offline Verfügbarkeit"
)
),
R.string.filedetails_sync_file to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Offline availability",
Locale.GERMAN to "Offline Verfügbarkeit"
)
),
R.string.action_send_share to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Sharing",
Locale.GERMAN to "Teilen"
)
),
R.string.common_cancel_sync to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Cancel",
Locale.GERMAN to "Abbrechen"
)
),
R.string.instant_upload_path to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "/Camera-Media",
Locale.GERMAN to "/Kamera-Medien"
)
),
R.string.prefs_synced_folders_remote_path_title to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Target folder in your MagentaCLOUD",
Locale.GERMAN to "Zielorder in Deiner MagentaCLOUD"
)
),
R.string.prefs_e2e_mnemonic to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "End-to-end encryption",
Locale.GERMAN to "Ende-zu-Ende Verschlüsselung"
)
),
R.string.storage_choose_location to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Choose Source",
Locale.GERMAN to "Wählen Sie Quelle"
)
),
R.string.subtitle_photos_videos to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Images and videos",
Locale.GERMAN to "Fotos und Videos"
)
),
R.string.show_images to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Show images",
Locale.GERMAN to "Bilder anzeigen"
)
),
R.string.subtitle_photos_only to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Images only",
Locale.GERMAN to "Nur Fotos"
)
),
R.string.select_media_folder to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Select the \"Media\" folder",
Locale.GERMAN to "Den Ordner \"Medien\" auswählen",
)
),
R.string.file_already_exists to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Filename already exists.",
Locale.GERMAN to "Dateiname bereits vorhanden",
)
),
R.string.email_pick_failed to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Failed to pick email address.",
Locale.GERMAN to "Fehler beim Zugriff auf E-Mail Adresse.",
)
),
R.string.menu_item_sort_by_date_newest_first to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Newest first",
Locale.GERMAN to "Neueste zuerst",
)
),
R.string.update_link_file_error to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "An error occurred while trying to update the share.",
Locale.GERMAN to "Fehler bei der Aktualisierungd der Freigabe aufgetreten.",
)
),
R.string.file_list_empty_unified_search_start_search_description to ExpectedLocalizedString(
translations = mapOf(
Locale.ENGLISH to "Search for files and folders",
Locale.GERMAN to "Dateien und Ordner suchen",
)
),
)
@Test
fun verifyLocalizedStrings() {
localizedStringMap.forEach { (stringRes, expected) ->
expected.translations.forEach { (locale, expectedText) ->
val config = Configuration(baseContext.resources.configuration)
config.setLocale(locale)
val localizedContext = baseContext.createConfigurationContext(config)
val actualText = localizedContext.getString(stringRes)
assertEquals(
"Mismatch for ${baseContext.resources.getResourceEntryName(stringRes)} in $locale",
expectedText,
actualText
)
}
}
}
data class ExpectedLocalizedString(val translations: Map<Locale, String>)
}