1
votes

I have localized my Xamarin.Forms project (PCL approach). Additionally, I added another PCL as reference to this project by referencing the output dll from the Debug folder. This PCL is also localized after the same approach like the Xamarin.Forms project by using RESX files and setting the culture with AppResources.Culture = ci;

The current issue is, that this works as expected on my local machine, but not on the build server (Jenkins calling MSBuild). The difference also is that I work in the Debug mode, the generated apk file (Android) is build in the Release mode. But regardless of the mode, locally the localization is working fine in both modes! On the build server the resulting apk file contains now a mixture of two languages:

  • Localized strings according to the current device language (Xamarin.Forms project)
  • Non localized strings from the additional PCL (only showing strings from the language neutral RESX file)

Now I don't understand why this works locally, but not on the build server side. What I tried:

  • I logged the culture in the "faulty" generated apk from the build server and it is correctly set (in both the app and the additional PCL)
  • I checked the loaded resources and one AppResources.resources is showing up (apparently it contains all RESX files including the language-specific resources?)
  • I tried to locally call MSBuild similar to the task done on the Jenkins build server, but as always, locally it is working fine
  • Followed the instructions from Xamarin, but I didn't find any solution
  • Device culture is e.g. en-US, but my language neutral RESX file is set to en. I tried to add a AppResources.en-US.resx file to the additional PCL, but the system still shows the content from the language neutral RESX file.

Is this a configuration issue on the build server in combination with MSBuild? If yes, what is different or missing? Or is this a code issue? Is this a problem using the same name AppResources for localization in both projects (XF and additional PCL)? Do you have any hints for me to find this issue?

1

1 Answers

0
votes

The issue was that the result of the PCL (a dll) was copied to the XF project. But the build artefacts of the PCL also contains language specific resources (called satellite assembly). The folder structure looks like the following:

MyLib/bin/Debug/MyLib.dll
MyLib/bin/Debug/en/MyLib.resources.dl

The folder en depends on your supported languages and can differ. If I copy all the required files with the same folder structure to the XF project, the translation works as expected. That was the reason, why it worked locally. It seems, that it isn't necessary to set the Culture in the resource files of the additional PCL.