1

I was wondering if anyone has seen if it is possible to get string resources from another directory. So by default my strings are in something like:

/MyProject/src/main/res/values and translated languages in /MyProject/src/main/res/values-es etc...

I would like to get my string resources from another file or sub-directory like:

/MyProject/sub-module/src/res/values but also have it get values for translated languages the same: /MyProject/sub-module/src/res/values-es

I have looked around in the developer documents and other resources but have seen nothing about changing the directory of the strings resources.

dev
  • 1,343
  • 2
  • 19
  • 40
ocross
  • 593
  • 1
  • 5
  • 24

1 Answers1

4

The gradle tools let you move the entire res/ folder with everything in it, but not only the string resources. It's now possible to use sub-folders, so you if you're on Mac or Linux could probably make something work using symlinks.

Moving the entire res/ folder in gradle:

sourceSets {
    main {
        resources {
            srcDir 'sub-module/src/res'
        }
    }
}

The symlinks approach (I haven't tried this, but it might work):

project/
  src/
    main/
      java/
      res/
        values/
          dimens.xml
          strings/       <--- actually a symlink to another folder
            strings.xml
        values-en/
          strings/       <--- actually a symlink to another folder
            strings.xml
Community
  • 1
  • 1
Barend
  • 17,296
  • 2
  • 61
  • 80
  • Awesome thank you for this. I am surprised I could not find anything on this. The symlink approach sounds interesting is there anyway I could make it scalable through git? Or would I have to write some sort of setup.sh to run and add the symlinks? – ocross Jul 21 '15 at 18:38
  • 1
    I haven't tried that ever, but it seems Git can handle symlinks reasonably well: http://stackoverflow.com/a/954575/49489 – Barend Jul 21 '15 at 18:52