Skip to content

Commit

Permalink
Translations: disable zh code (#11385)
Browse files Browse the repository at this point in the history
* Translations: disable `zh` code

The code `zh` is invalid and project shouldn't select it. They should use `zh-*`
instead. This was causing issues when rendering the new dashboard.

This step only disable this language code so new projects cannot select it.
However, we still need to decide what to do with the db and write a data
migration for them. I suppose that most of them are probably spam, tho.

* Add issue to track the TODO

* Migration
  • Loading branch information
humitos committed Jun 12, 2024
1 parent 985f8bb commit 0580934
Show file tree
Hide file tree
Showing 2 changed files with 382 additions and 1 deletion.
10 changes: 9 additions & 1 deletion readthedocs/projects/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,15 @@
("yi", "Yiddish"),
("yo", "Yoruba"),
("za", "Zhuang"),
("zh", "Chinese"),
# TODO: migrate those projects that are currently using "zh" as language.
# This is an invalid language code, so the first step is remove it from the
# list of possible languages.
# https://github.com/readthedocs/readthedocs.org/issues/11387
#
# In [1]: Project.objects.filter(language='zh').count()
# Out[1]: 1485
#
# ("zh", "Chinese"),
("zu", "Zulu"),
# Try these to test our non-2 letter language support
("nb-no", "Norwegian Bokmal"),
Expand Down
373 changes: 373 additions & 0 deletions readthedocs/projects/migrations/0124_remove_zh_locale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,373 @@
# Generated by Django 4.2.13 on 2024-06-12 10:24

from django.db import migrations, models
from django_safemigrate import Safe


class Migration(migrations.Migration):
safe = Safe.after_deploy

dependencies = [
("projects", "0123_deprecate_old_vcs"),
]

operations = [
migrations.AlterField(
model_name="historicalproject",
name="language",
field=models.CharField(
choices=[
("aa", "Afar"),
("ab", "Abkhaz"),
("acr", "Achi"),
("af", "Afrikaans"),
("agu", "Awakateko"),
("am", "Amharic"),
("ar", "Arabic"),
("as", "Assamese"),
("ay", "Aymara"),
("az", "Azerbaijani"),
("ba", "Bashkir"),
("be", "Belarusian"),
("bg", "Bulgarian"),
("bh", "Bihari"),
("bi", "Bislama"),
("bn", "Bengali"),
("bo", "Tibetan"),
("br", "Breton"),
("ca", "Catalan"),
("caa", "Ch'orti'"),
("cac", "Chuj"),
("cab", "Garífuna"),
("cak", "Kaqchikel"),
("co", "Corsican"),
("cs", "Czech"),
("cy", "Welsh"),
("da", "Danish"),
("de", "German"),
("dz", "Dzongkha"),
("el", "Greek"),
("en", "English"),
("eo", "Esperanto"),
("es", "Spanish"),
("et", "Estonian"),
("eu", "Basque"),
("fa", "Iranian"),
("fi", "Finnish"),
("fj", "Fijian"),
("fo", "Faroese"),
("fr", "French"),
("fy", "Western Frisian"),
("ga", "Irish"),
("gd", "Scottish Gaelic"),
("gl", "Galician"),
("gn", "Guarani"),
("gu", "Gujarati"),
("ha", "Hausa"),
("hi", "Hindi"),
("he", "Hebrew"),
("hr", "Croatian"),
("hu", "Hungarian"),
("hy", "Armenian"),
("ia", "Interlingua"),
("id", "Indonesian"),
("ie", "Interlingue"),
("ik", "Inupiaq"),
("is", "Icelandic"),
("it", "Italian"),
("itz", "Itza'"),
("iu", "Inuktitut"),
("ixl", "Ixil"),
("ja", "Japanese"),
("jac", "Popti'"),
("jv", "Javanese"),
("ka", "Georgian"),
("kjb", "Q'anjob'al"),
("kek", "Q'eqchi'"),
("kk", "Kazakh"),
("kl", "Kalaallisut"),
("km", "Khmer"),
("kn", "Kannada"),
("knj", "Akateko"),
("ko", "Korean"),
("ks", "Kashmiri"),
("ku", "Kurdish"),
("ky", "Kyrgyz"),
("la", "Latin"),
("ln", "Lingala"),
("lo", "Lao"),
("lt", "Lithuanian"),
("lv", "Latvian"),
("mam", "Mam"),
("mg", "Malagasy"),
("mi", "Maori"),
("mk", "Macedonian"),
("ml", "Malayalam"),
("mn", "Mongolian"),
("mop", "Mopan"),
("mr", "Marathi"),
("ms", "Malay"),
("mt", "Maltese"),
("my", "Burmese"),
("na", "Nauru"),
("ne", "Nepali"),
("nl", "Dutch"),
("no", "Norwegian"),
("oc", "Occitan"),
("om", "Oromo"),
("or", "Oriya"),
("pa", "Panjabi"),
("pl", "Polish"),
("pnb", "Western Punjabi"),
("poc", "Poqomam"),
("poh", "Poqomchi"),
("ps", "Pashto"),
("pt", "Portuguese"),
("qu", "Quechua"),
("quc", "K'iche'"),
("qum", "Sipakapense"),
("quv", "Sakapulteko"),
("rm", "Romansh"),
("rn", "Kirundi"),
("ro", "Romanian"),
("ru", "Russian"),
("rw", "Kinyarwanda"),
("sa", "Sanskrit"),
("sd", "Sindhi"),
("sg", "Sango"),
("si", "Sinhala"),
("sk", "Slovak"),
("skr", "Saraiki"),
("sl", "Slovenian"),
("sm", "Samoan"),
("sn", "Shona"),
("so", "Somali"),
("sq", "Albanian"),
("sr", "Serbian"),
("ss", "Swati"),
("st", "Southern Sotho"),
("su", "Sudanese"),
("sv", "Swedish"),
("sw", "Swahili"),
("ta", "Tamil"),
("te", "Telugu"),
("tg", "Tajik"),
("th", "Thai"),
("ti", "Tigrinya"),
("tk", "Turkmen"),
("tl", "Tagalog"),
("tn", "Tswana"),
("to", "Tonga"),
("tr", "Turkish"),
("ts", "Tsonga"),
("tt", "Tatar"),
("ttc", "Tektiteko"),
("tzj", "Tz'utujil"),
("tw", "Twi"),
("ug", "Uyghur"),
("uk", "Ukrainian"),
("ur", "Urdu"),
("usp", "Uspanteko"),
("uz", "Uzbek"),
("vi", "Vietnamese"),
("vo", "Volapuk"),
("wo", "Wolof"),
("xh", "Xhosa"),
("xin", "Xinka"),
("yi", "Yiddish"),
("yo", "Yoruba"),
("za", "Zhuang"),
("zu", "Zulu"),
("nb-no", "Norwegian Bokmal"),
("pt-br", "Brazilian Portuguese"),
("es-mx", "Mexican Spanish"),
("uk-ua", "Ukrainian"),
("zh-cn", "Simplified Chinese"),
("zh-tw", "Traditional Chinese"),
],
default="en",
help_text="The language the project documentation is rendered in. Note: this affects your project's URL.",
max_length=20,
verbose_name="Language",
),
),
migrations.AlterField(
model_name="project",
name="language",
field=models.CharField(
choices=[
("aa", "Afar"),
("ab", "Abkhaz"),
("acr", "Achi"),
("af", "Afrikaans"),
("agu", "Awakateko"),
("am", "Amharic"),
("ar", "Arabic"),
("as", "Assamese"),
("ay", "Aymara"),
("az", "Azerbaijani"),
("ba", "Bashkir"),
("be", "Belarusian"),
("bg", "Bulgarian"),
("bh", "Bihari"),
("bi", "Bislama"),
("bn", "Bengali"),
("bo", "Tibetan"),
("br", "Breton"),
("ca", "Catalan"),
("caa", "Ch'orti'"),
("cac", "Chuj"),
("cab", "Garífuna"),
("cak", "Kaqchikel"),
("co", "Corsican"),
("cs", "Czech"),
("cy", "Welsh"),
("da", "Danish"),
("de", "German"),
("dz", "Dzongkha"),
("el", "Greek"),
("en", "English"),
("eo", "Esperanto"),
("es", "Spanish"),
("et", "Estonian"),
("eu", "Basque"),
("fa", "Iranian"),
("fi", "Finnish"),
("fj", "Fijian"),
("fo", "Faroese"),
("fr", "French"),
("fy", "Western Frisian"),
("ga", "Irish"),
("gd", "Scottish Gaelic"),
("gl", "Galician"),
("gn", "Guarani"),
("gu", "Gujarati"),
("ha", "Hausa"),
("hi", "Hindi"),
("he", "Hebrew"),
("hr", "Croatian"),
("hu", "Hungarian"),
("hy", "Armenian"),
("ia", "Interlingua"),
("id", "Indonesian"),
("ie", "Interlingue"),
("ik", "Inupiaq"),
("is", "Icelandic"),
("it", "Italian"),
("itz", "Itza'"),
("iu", "Inuktitut"),
("ixl", "Ixil"),
("ja", "Japanese"),
("jac", "Popti'"),
("jv", "Javanese"),
("ka", "Georgian"),
("kjb", "Q'anjob'al"),
("kek", "Q'eqchi'"),
("kk", "Kazakh"),
("kl", "Kalaallisut"),
("km", "Khmer"),
("kn", "Kannada"),
("knj", "Akateko"),
("ko", "Korean"),
("ks", "Kashmiri"),
("ku", "Kurdish"),
("ky", "Kyrgyz"),
("la", "Latin"),
("ln", "Lingala"),
("lo", "Lao"),
("lt", "Lithuanian"),
("lv", "Latvian"),
("mam", "Mam"),
("mg", "Malagasy"),
("mi", "Maori"),
("mk", "Macedonian"),
("ml", "Malayalam"),
("mn", "Mongolian"),
("mop", "Mopan"),
("mr", "Marathi"),
("ms", "Malay"),
("mt", "Maltese"),
("my", "Burmese"),
("na", "Nauru"),
("ne", "Nepali"),
("nl", "Dutch"),
("no", "Norwegian"),
("oc", "Occitan"),
("om", "Oromo"),
("or", "Oriya"),
("pa", "Panjabi"),
("pl", "Polish"),
("pnb", "Western Punjabi"),
("poc", "Poqomam"),
("poh", "Poqomchi"),
("ps", "Pashto"),
("pt", "Portuguese"),
("qu", "Quechua"),
("quc", "K'iche'"),
("qum", "Sipakapense"),
("quv", "Sakapulteko"),
("rm", "Romansh"),
("rn", "Kirundi"),
("ro", "Romanian"),
("ru", "Russian"),
("rw", "Kinyarwanda"),
("sa", "Sanskrit"),
("sd", "Sindhi"),
("sg", "Sango"),
("si", "Sinhala"),
("sk", "Slovak"),
("skr", "Saraiki"),
("sl", "Slovenian"),
("sm", "Samoan"),
("sn", "Shona"),
("so", "Somali"),
("sq", "Albanian"),
("sr", "Serbian"),
("ss", "Swati"),
("st", "Southern Sotho"),
("su", "Sudanese"),
("sv", "Swedish"),
("sw", "Swahili"),
("ta", "Tamil"),
("te", "Telugu"),
("tg", "Tajik"),
("th", "Thai"),
("ti", "Tigrinya"),
("tk", "Turkmen"),
("tl", "Tagalog"),
("tn", "Tswana"),
("to", "Tonga"),
("tr", "Turkish"),
("ts", "Tsonga"),
("tt", "Tatar"),
("ttc", "Tektiteko"),
("tzj", "Tz'utujil"),
("tw", "Twi"),
("ug", "Uyghur"),
("uk", "Ukrainian"),
("ur", "Urdu"),
("usp", "Uspanteko"),
("uz", "Uzbek"),
("vi", "Vietnamese"),
("vo", "Volapuk"),
("wo", "Wolof"),
("xh", "Xhosa"),
("xin", "Xinka"),
("yi", "Yiddish"),
("yo", "Yoruba"),
("za", "Zhuang"),
("zu", "Zulu"),
("nb-no", "Norwegian Bokmal"),
("pt-br", "Brazilian Portuguese"),
("es-mx", "Mexican Spanish"),
("uk-ua", "Ukrainian"),
("zh-cn", "Simplified Chinese"),
("zh-tw", "Traditional Chinese"),
],
default="en",
help_text="The language the project documentation is rendered in. Note: this affects your project's URL.",
max_length=20,
verbose_name="Language",
),
),
]

0 comments on commit 0580934

Please sign in to comment.