Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3768035
D468.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D468.diff
View Options
diff --git a/create_given_name b/create_given_name
--- a/create_given_name
+++ b/create_given_name
@@ -8,8 +8,9 @@
"""
import argparse
-import sys
+import json
import pywikibot
+import sys
# Usage: create_givenname.py [-h] givenname
parser = argparse.ArgumentParser(
@@ -50,18 +51,6 @@
item = pywikibot.ItemPage(repo, title=title)
item.get()
-labels = {
- 'fr': givenname,
- 'en': givenname
-}
-item.editLabels(labels, summary='Adding given name labels')
-
-description = {
- 'en': 'given name',
- 'fr': 'prénom'
-}
-item.editDescriptions(description, summary='Adding given name descriptions')
-
genre_items = {
'D': 'Q202444',
'M': 'Q12308941',
@@ -69,6 +58,22 @@
'U': 'Q3409032'
}
+l10n_files = {
+ 'D': 'l10n/givenname.json',
+ 'M': 'l10n/givenname-m.json',
+ 'F': 'l10n/givenname-f.json',
+ 'U': 'l10n/givenname-u.json'
+}
+
+# Gets descriptions from l10n file, and fill labels for these languages.
+l10n_file = l10n_files[genre]
+with open(l10n_file) as data_file:
+ descriptions = json.load(data_file)
+labels = {lang:givenname for lang in descriptions.keys()}
+
+item.editLabels(labels, summary='Adding given name labels')
+item.editDescriptions(descriptions, summary='Adding given name descriptions')
+
claim = pywikibot.Claim(repo, 'P31')
target = pywikibot.ItemPage(repo, genre_items[genre])
claim.setTarget(target)
diff --git a/create_surname b/create_surname
--- a/create_surname
+++ b/create_surname
@@ -7,6 +7,7 @@
"""
import argparse
+import json
import pywikibot
# usage: create_surname.py [-h] surname
@@ -40,17 +41,13 @@
item = pywikibot.ItemPage(repo, title=title)
item.get()
-labels = {
- 'fr': surname,
- 'en': surname
-}
-item.editLabels(labels, summary='Adding surname labels')
+# Gets descriptions from l10n file, and fill labels for these languages.
+with open('l10n/surname.json') as data_file:
+ descriptions = json.load(data_file)
+labels = {lang: surname for lang in descriptions.keys()}
-description = {
- 'en': 'family name',
- 'fr': 'nom de famille'
-}
-item.editDescriptions(description, summary='Adding surname descriptions')
+item.editLabels(labels, summary='Adding surname labels')
+item.editDescriptions(descriptions, summary='Adding surname descriptions')
claim = pywikibot.Claim(repo, 'P31')
target = pywikibot.ItemPage(repo, 'Q101352')
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 05:30 (7 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2256812
Default Alt Text
D468.diff (2 KB)
Attached To
Mode
D468: Localisation for create_surname and create_given_name (part 2)
Attached
Detach File
Event Timeline
Log In to Comment