This is a small library to help the developers who already using Localazy to localize their apps, aside that library support app language changing directly from it
In order to use this library, you need to setup Localazy Gradle Plugin. Guide can be found on official website Localazy Gradle Plugin
IMPORTANT THING Do not apply this configuration to the Localazy Gradle Plugin, because injection and download is important to retrieve your Language pack
localazy {
injection {
enabledForRelease false
enabledForDebug false
library "none"
}
download {
enabledForRelease false
enabledForDebug false
}
}
Since Localazy Card rely on Localazys OTA app needs INTERNET permission in order to work, add this code snippet to your Android Manifest, if you already done Localazy Gradle Plugin setup from the link above, you have done this step.
<uses-permission android:name="android.permission.INTERNET" />
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Include the library as a local library project or add the dependency in your build.gradle.
dependencies {
implementation 'com.github.Paget96:Localazy-Card:1.2'
}
By the default library will set a default view, you can easily manipulate it over xml or inside class.
Include the view defined as below in your layout. And you can customize it like this.
<com.paget96.localazycard.LocalazyCard
android:id="@+id/localazyCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:localazy_icon="@drawable/ic_localazy"
app:localazy_invitation_message="@string/localazy_default_invitation_text"
app:localazy_summary="@string/localazy_default_summary"
app:localazy_title="@string/localazy_default_title" />
override fun attachBaseContext(base: Context) {
super.attachBaseContext(onAttach(base))
}
val localazyCard = findViewById<LocalazyCard>(R.id.localazyCard)
// IMPORTANT, define activity for language changing
localazyCard.setActivity(this)
// Set card icon
localazyCard.setIcon(R.drawable.ic_localazy_no_bgd)
// Title text
localazyCard.setTitle(getString(R.string.translate) + " " + getString(R.string.app_name))
localazyCard.setTitleTextSize(18f)
localazyCard.setTitleTextStyle(Typeface.BOLD)
// Summary text
localazyCard.setSummaryText(getString(R.string.summary_text, getString(R.string.app_name)))
localazyCard.setSummaryTextSize(14f)
localazyCard.setSummaryTextStyle(Typeface.NORMAL)
// Open translation link
localazyCard.setTranslateButton()
// Invite to translate
localazyCard.setInviteButton(getString(R.string.invitation_text, getString(R.string.app_name)))
localazyCard.radius = 24f
localazyCard.strokeColor = ContextCompat.getColor(this, R.color.design_default_color_primary)
localazyCard.strokeWidth = 2
localazyCard.elevation = 0f
Add this to your strings file (those are default strings if you use configuration from step 2, this can be changed)
<string name="app_name">Localazy-Card</string>
<string name="translate">Translate</string>
<string name="summary_text">Help us to make %1$s app multilingual, translate it to 50+ languages</string>
<string name="invitation_text">I\'m inviting you to help translating %1$s</string>
<string name="this_is_test_1">This is test 1</string>
<string name="this_is_test_2">This is test 2</string>
<string name="this_is_test_3">This is test 3</string>
Since this library is basically an extended view of a MaterialCardView, you can use pretty much the same features as the default material card have
localazyCard.radius = 24f // Set card corner radius
localazyCard.setStrokeColor(ContextCompat.getColor(this, R.color.design_default_color_primary)) // Set stroke color
localazyCard.strokeWidth = 2 // Set stroke width
localazyCard.elevation = 0f // Set card elevation
// And much more
- Converted code to Kotlin
- Design overhaul
- Updated implementation
- Changed base functionality
- Added Localazy library to get and set languages
- Removed useless parts of the code
- Set buttons to public, manipulation on them "enabled"
- Updated card design
- Added feature to change app language directly from the app
- Updated library code
- Exported strings
- Added invitation button
- Slightly updated card view
- Updated app example
- Added changing text size and style