GithubHelp home page GithubHelp logo

koral-- / android-gradle-localization-plugin Goto Github PK

View Code? Open in Web Editor NEW
109.0 9.0 20.0 1.04 MB

Gradle plugin for generating localized string resources

License: MIT License

Groovy 100.00%
gradle plugin i18n xml csv xls xlsx android internationalization l10n

android-gradle-localization-plugin's Introduction

Hi 👋 I’m Karol

I’m experienced Mobile Developer with over 12 years of expertise in native Android and Flutter app development.

Skilled in creating Gradle plugins and Bitrise steps. Engaged in various projects, especially focusing on testing.

A speaker at conferences and meetups such as DevFest, Flutter Global Summit, Mobile DevOps Summit, JDD Conference, Linux Academy, and more.

Actively involved as a lead of Google Developers Group Wrocław, Flutter Wrocław, and Bitrise User Group.

GitHub stats Top Langs

Linkedin Gmail Twitter Medium

android-gradle-localization-plugin's People

Contributors

cryosleeper avatar ihrthk avatar koral-- avatar michallankof avatar nonda95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-gradle-localization-plugin's Issues

Problem with question marks "?"

At some point, an issues surface that question marked are being "escaped" with a "" in front of them, I suspected this started when I started working on OSX

Any hints?

Call created file something else

If you are indeed overwriting strings.xml every time we run the gradle task, you should consider naming it something else such as "strings_generated.xml" or giving us the option to configure the file name but definitely should NOT default to strings.xml.

Reverse: xml to csv?

Any way we could do xml to csv?
Idea is for developers to have control over the strings and to be able to refactor them when necessary, next 'xml -> csv' and to the Google Docs for translation. When translation is finished 'csv -> xml' to update localization.

Default locale column not present

When I try to run task after added new strings in spreadsheets , I am getting this error

  • What went wrong:
    Execution failed for task ':app:localization'.

Default locale column not present

please, can somebody help me?

ask two question

1.mBuilder.resources(MarkupBuilder),MarkupBuilder don't have resources method?
2.what mean is string(attrs)?

column index instead of nameColumnName

Sometimes translators dont' use name for 'name column'. Also very often this is the first column.

The example:

en fr it fi
text en_text fr_text it_text fi_text

Could you add option to use column index instead of column name ?

Kotlin DSL configuration causes incorrect column parsing with xlsx intermediate format

Preconditions:

  • Newly created Google Sheet with columns "name" and "default" with a single entry ("test", "Test")
  • Plugin version 1.0.17
  • Kotlin DSL configuration as such (top-level in module-level build file):
localization {
    xlsFileURI = "https://docs.google.com/spreadsheets/d/REDACTED/export?format=xlsx"
    handleEmptyTranslationsAsDefault = true
    allowEmptyTranslations = true
    outputIndent = "    "
    skipInvalidName = true
}
  • ./gradlew localization executed

Expected results:

  • values/strings.xml created containing:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="test">Test</string>
</resources>

Actual results:

  • values/strings.xml created containing:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="test">Test</string>
</resources>
  • values-/strings.xml created containing:
<?xml version="1.0" encoding="UTF-8"?>
<resources/>

Steps taken to investigate:

  1. Tried reproducing the issue in a different project with:
  • Same XLSX uri
  • Same plugin version
  • Same project contents
  • Same gradle config
  • Only difference (As far as I can tell) is that instead of Gradle Kotlin DSL, traditional Gradle Groovy is used.
    The issue is not existent in this different project.
  1. Using existing sheets working properly in different (Groovy-based) projects. The issue persists in the Kotlin-DSL-based project

Workarounds that fix the issue

Either:

  • Adding ignorableColumns = listOf("") to config block fixes the issue. Seems like an unnecessary hack.
  • Changing xlsFileURI = "https://docs.google.com/spreadsheets/d/REDACTED/export?format=xlsx" to csvFileURI = "https://docs.google.com/spreadsheets/d/REDACTED/export?format=csv"

Notes

I might be wrong and the issue might stem from a different source. I think it's important the plugin is tested with Kotlin Gradle DSL projects.

If needed, I remain at your disposal to further investigate the issue

Call new folder for res dir structure

Because In android gradle plugin,the res dir to be configured. You should consider res dir structure it something else such as "res" or giving us the option to configure the res dir but definitely should NOT default to "src/main/res".

4 spaces instead of 2

I think there should be possibility to configure how many spaces will be added before "" tag.

Can I use this plugin with multiple flavours with different localizations ?

I have a project with 2 flavours. I want to have different strings for both flavours. We have small amount of strings that differ between the flavours so I want to have a single excel file with two spreadsheets - one containing all the strings used in the first flavour (the main one) and a second spreadsheet containing only the strings that differ in the second flavour, overriding the main strings (placing it inside the second flavour source sets). Is this possible with the current implementation ?

How can i avoid escaping newline character

In app.gradle

localization {
  csvFile = file('strings.csv')
  outputIndent = '  '
  defaultColumnName = 'en'
  escapeNewLines = false
  handleEmptyTranslationsAsDefault = 'true'
  outputFileName = 'strings.xml'
}

In strings.csv i have the next line
tutorial_analyses_title,"Analyses order \n DoctorOnline",,"",,,,,,,,,,

but after executing task localization i get such string after parsing in strings.xml

<string name="tutorial_analyses_title">Analyses order \\n DoctorOnline</string>

As a result string cannot be displayed in textView correctly. How can I avoid escaping this character? escapeNewLines = false config seems to be ignored. How can i avoid escaping this newline character?

Plugin version 1.0.19.

Thanks for help

Gradle 8 Support

The library does not support Gradle 8 and above, I ran into a few problems.

Task :app:localization FAILED
Caching disabled for task ':app:localization' because:
  Caching has not been enabled for the task
Task ':app:localization' is not up-to-date because:
  Task has not declared any outputs despite executing actions.

Execution failed for task ':app:localization'.
> Could not get unknown property 'outputDirectory' for task ':app:localization' of type pl.droidsonroids.gradle.localization.LocalizationTask.

Are there any gradle command can display task properties?

PS:In order to make user of user the gradle plugin can be more conveniently and clearly to use the plugin.

Maybe Like this:

gradle -task localization properties

File sourceFile
File outRes;
File inRes;
Map<String, String> map;
boolean append = true
boolean replace = true
File report;
String csvFileURI
String csvGenerationCommand
ArrayList<String> ignorableColumns = []
CSVStrategy csvStrategy
String outputFileName = 'strings.xml'
String outputIndent = '    '
String name = "name";
String translatable = "translatable";
String comment = "comment"
boolean skipInvalidName = true
boolean skipDuplicatedName = true

Java version error

Error during build:

Error:(29) A problem occurred evaluating project ':app'.

pl/droidsonroids/gradle/localization/LocalizationPlugin : Unsupported major.minor version 52.0

Skip empty plural

What about applying allowEmptyTranslations to plurals? It is actually breaking my parsing since some of my language variants don't require specific translation to plurals.

about csvGenerationCommand

Assume i have a file in d:/language_append_CMSD_100_rev.xls ,How i use to about csvGenerationCommand? thanks.

gradle localization failed

plugins {
id "pl.droidsonroids.localization" version "1.0.8"
}

localization {
xlsFile = file('language_iOS_append_ALL_343_RC_20150522v2.xlsx')
allowEmptyTranslations = true
defaultColumnName = "EN"
name = "Android"
ignorableColumns = ['WinPhone', 'iOS', 'END']
outputDirectory file('outRes')
sheetName "string table"
}

D:\studio_workspace\android\lite>gradle localization

FAILURE: Build failed with an exception.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.