i18nliner-kt | I18n made simple - for Kotlin | Internationalization library

 by   edwardsCam Kotlin Version: Current License: MIT

kandi X-RAY | i18nliner-kt Summary

kandi X-RAY | i18nliner-kt Summary

i18nliner-kt is a Kotlin library typically used in Utilities, Internationalization, React applications. i18nliner-kt has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

I18n made simple - for Kotlin! (still in beta)
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              i18nliner-kt has a low active ecosystem.
              It has 9 star(s) with 3 fork(s). There are 2 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              i18nliner-kt has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of i18nliner-kt is current.

            kandi-Quality Quality

              i18nliner-kt has no bugs reported.

            kandi-Security Security

              i18nliner-kt has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              i18nliner-kt is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              i18nliner-kt releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of i18nliner-kt
            Get all kandi verified functions for this library.

            i18nliner-kt Key Features

            No Key Features are available at this moment for i18nliner-kt.

            i18nliner-kt Examples and Code Snippets

            No Code Snippets are available at this moment for i18nliner-kt.

            Community Discussions

            Trending Discussions on i18nliner-kt

            QUESTION

            How to support i18n with kotlin js
            Asked 2020-Nov-11 at 12:55

            i'm currently trying to add i18n support to a kotlin js project (no react).

            ...

            ANSWER

            Answered 2020-Nov-11 at 12:55
            class LanguageSupport(private val folder: String = "", private val lang: String) {
                private lateinit var currentLang: Json
            
                private val languageMutableStateFlow = MutableStateFlow(
                    LanguageSupportState.LanguageInit
                )
                val languageStateFlow: StateFlow = languageMutableStateFlow
            
                init {
                    loadJSON()
                }
            
                fun get(key: String): String {
                    val value = currentLang[key]
                    check(value != null) {
                        throw Exception("key not found to load language definition")
                    }
                    return if (value is String) {
                        value
                    } else {
                        throw Exception("value of key is not a string")
                    }
                }
            
                fun get(key: String, vararg placeholders: String): String {
                    val value = currentLang[key]
                    check(value != null) {
                        throw Exception("key not found to load language definition")
                    }
                    return if (value is String) {
                        var finalValue: String = value
                        for (item in placeholders) {
                            finalValue = finalValue.replaceFirst(PLACEHOLDER, item)
                        }
                        finalValue
                    } else {
                        throw Exception("value of key is not a string")
                    }
                }
            
                private fun loadJSON() {
                    val xobj = XMLHttpRequest()
                    xobj.overrideMimeType("application/json")
                    xobj.open("GET", "${folder}test_${lang}.json", true)
                    xobj.onreadystatechange = {
            
                        if (xobj.readyState.toInt() == 4 && xobj.status.toInt() == 200) {
                            // Required use of an anonymous callback
                            // as .open() will NOT return a value but simply returns undefined in asynchronous mode
                            currentLang = JSON.parse(xobj.responseText)
                            languageMutableStateFlow.value = LanguageSupportState.LanguageLoaded
                        }
                    }
                    xobj.send(null)
                }
            
                companion object {
                    const val PLACEHOLDER = "%s"
                }
            }
            
            sealed class LanguageSupportState {
                object LanguageLoaded : LanguageSupportState()
                object LanguageError : LanguageSupportState()
                object LanguageInit : LanguageSupportState()
            }
            

            Source https://stackoverflow.com/questions/64765248

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install i18nliner-kt

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/edwardsCam/i18nliner-kt.git

          • CLI

            gh repo clone edwardsCam/i18nliner-kt

          • sshUrl

            git@github.com:edwardsCam/i18nliner-kt.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Internationalization Libraries

            formatjs

            by formatjs

            react-i18next

            by i18next

            version

            by sebastianbergmann

            globalize

            by globalizejs

            angular-translate

            by angular-translate

            Try Top Libraries by edwardsCam

            Wyzziweb

            by edwardsCamJavaScript

            generative

            by edwardsCamJavaScript

            Dinosaur

            by edwardsCamJavaScript

            huntsman

            by edwardsCamJavaScript

            timeout-chain

            by edwardsCamJavaScript