IDEA-254595 language plugin suggestion: try language if locale failed
authorDmitry.Krasilschikov <kradima@jetbrains.com>
Sun, 29 Nov 2020 18:12:12 +0000 (20:12 +0200)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Sun, 29 Nov 2020 18:13:21 +0000 (18:13 +0000)
GitOrigin-RevId: 9ca29c2403eafdb6b99ab5d42a652ef562ed2b91

platform/platform-impl/src/com/intellij/ide/LanguageDetector.kt

index 385bcd7cb8ac303225c620c5cfbe92e38751f2f0..836438a4a763149d3d5cb354f8da0dbfd590e603 100644 (file)
@@ -26,8 +26,14 @@ class LanguageDetector : StartupActivity.Background {
 
   companion object {
     private fun matchedLanguagePlugins(): List<FeatureImpl> {
+      val features = getFeatures(Locale.getDefault().toLanguageTag())
+      if (features.isNotEmpty()) return features
+
+      return getFeatures(Locale.getDefault().language)
+    }
+
+    private fun getFeatures(languageTag: String): List<FeatureImpl> {
       val build = MarketplaceRequests.getInstance().getBuildForPluginRepositoryRequests()
-      val languageTag = Locale.getDefault().toLanguageTag()
       val params = mapOf("featureType" to "com.intellij.locale", "implementationName" to languageTag, "build" to build)
       return MarketplaceRequests.getInstance().getFeatures(params)
     }