Bug 29217 - String tables in *.lproj folders not loaded when RESX resources from a PCL for the same language are included.
Summary: String tables in *.lproj folders not loaded when RESX resources from a PCL fo...
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: master
Hardware: PC Windows
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-04-17 21:38 UTC by Jon Goldberger [MSFT]
Modified: 2015-04-20 17:26 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jon Goldberger [MSFT] 2015-04-17 21:38:42 UTC
## Description

When an iOS project is referencing PCLs that have RESX files for localization for some languages then the localization string table resources in the *.lproj for the same language are not loaded by the iOS runtime. The *.lproj folders, with the *.strings files are in the final bundle, but the error received at runtime is "Unable to load string table". 

## Steps to reproduce

1. Download the solution from the link in the private comment below (as it is a full solution, please keep solution private and don't post screenshots, etc, in public comments.)

2. Open the Apollo.sln in Visual Studio and set the iOS app project to be the startup project.

3. Open the iOS simulator (or device) and set the language to French, Spanish, German, or Turkish (tr?)

4. Deploy the iOS App to the device/simulator in debug configuration.

Expected result: Page will have French translations (though I note not all strings have been translated in the fr.lproj file)

Actual result: Only English is shown and error in Console is: "Unable to load string table"

## Notes

As english is the only language in the iOS app project that has an en.lproj file and strng tables in it, but no RESX localization resources, you can verify that native iOS localization is set up properly by changing the device/sim language to English and seeing that you do not receive that error, or even better put some unique text for "Enter your credentials to login." string in the MainStoryboard_iPad.strings file and the MainStoryboard_iPhone.strings files in the en.lproj folder and then run the app on a device/sim set to English and you will see the unique string at the top of the screen upon launch.

I have verified that all of the *.lproj folders and the *.strings files are present in the final app bundle, so it is not an issue of the resources not getting copied to the bundle or the files not being found... as shown by the ability for iOS to find the en.lproj folder and the files within. 

The customer who reported this to us said that all of the localizations that are in the RESX files are able to be loaded and used without issue. I did not verify this. They also report that this used to work, but months ago when they last worked on the project. 

I tested on both Simulator (iPad Air 2 iOS 8.3) and device (iPhone 5s iOS 8.3) with the same results on each. 

I also verified that the iOS localization part seems to be set up correctly. This is also evidenced by the English localization working correctly.

## My Environment

Microsoft Visual Studio Ultimate 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.53349

Installed Version: Ultimate

Architecture and Modeling Tools   06181-004-0451031-02209
Microsoft Architecture and Modeling Tools
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

LightSwitch for Visual Studio 2013   06181-004-0451031-02209
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06181-004-0451031-02209
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06181-004-0451031-02209
Microsoft Visual Basic 2013

Visual C# 2013   06181-004-0451031-02209
Microsoft Visual C# 2013

Visual C++ 2013   06181-004-0451031-02209
Microsoft Visual C++ 2013

Visual F# 2013   06181-004-0451031-02209
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06181-004-0451031-02209
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06181-004-0451031-02209
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.4.51016.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.21010.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.3
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone

Microsoft Azure HDInsight HQL Service   1.0.0000.0
Language service for Hive query

Microsoft Azure HDInsight Tools for Visual Studio   1.0.0000.0
An integrated development environment for HDInsight application development.

Microsoft Azure Mobile Services Tools   1.3
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools   2.4
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.4.20730.1601

Microsoft Azure Tools   2.5
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.5.21104.1601

Multilingual App Toolkit   3.1.1250.0
Multilingual App Toolkit helps you localize your Windows Store app by providing file management, pseudo and machine translation, translation editor, and build integration. http://go.microsoft.com/fwlink?linkid=245767

NuGet Package Manager   2.8.50926.663
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.31105
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools   1.3
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   12.0.41025.0
Microsoft SQL Server Data Tools

Windows Azure Tools   2.3
Windows Azure Tools for Microsoft Visual Studio 2013 - v2.3.20320.1602

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   3.9.547.0 (20fd2f0)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (86274adfc6418b4c3a9d67734eb871163859b51c)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS (02a05754f85064ec222c8a1a975761debfe7122d)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified
Comment 4 Jon Goldberger [MSFT] 2015-04-20 15:29:16 UTC
Marking as new as info was provided. Also changing back to public as bug report was changed to private by mistake.
Comment 5 Jon Goldberger [MSFT] 2015-04-20 15:43:36 UTC
Related bug report for VS: https://bugzilla.xamarin.com/show_bug.cgi?id=29252
Comment 6 Sebastien Pouliot 2015-04-20 15:46:33 UTC
This is an classic project and the "optimizing strings" step is done by the XS iOS addin [1].

The error I get (comment #2) is, at least in part, because the file is _not_ copied from the project to where `plutil` is called. IOW the input to `plutil` does not exists and the tool gives a weird, unrelated (json) error (which confuse things further). It _might_ be simply a bug in the copy logic (as it's not possible to set a build action on them).

[1] Once working that will need to be verified for unified too (that would be in msbuild, XI);
Comment 7 Jeffrey Stedfast 2015-04-20 16:02:22 UTC
I'm confused...

plutil -convert binary1 -o "/Users/poupou/Downloads/1.12/Apollo.iOS/bin/iPhoneSimulator/Debug/ApolloiOS.app/en.lproj/MainStoryboard_iPhone.strings"

The first path (after the -o) is the output path. The second path is the path of the file in the project. There's no need to copy the file to the output path before calling plutil... that's what plutil is supposed to do.

If you mean to say that /Users/poupou/Downloads/1.12/Apollo.iOS/Resources/en.lproj/MainStoryboard_iPhone.strings does not exist... then that's a problem, for sure, but not *our* problem :-)
Comment 8 Sebastien Pouliot 2015-04-20 16:10:10 UTC
Well I missed the -o in the noise - and you were the right person to spot that :-)

Does anything looks strange in the .strings files ? They looked fine to me - but I never looked much at them ?
Comment 9 Jeffrey Stedfast 2015-04-20 16:31:09 UTC
No, they look like normal strings files to me. But, like you, I haven't looked at many strings files so that's not a definitive assessment.
Comment 10 Sebastien Pouliot 2015-04-20 17:01:18 UTC
It's a file encoding issue. If the files are detected as:

/Apollo.iOS/Resources/es.lproj/Localizable.strings: ISO-8859 c program text, with CRLF, LF line terminators

the `plutil` won't accept them. If I save this file to UTF8 then it works correctly

$ file "Apollo.iOS/Resources/es.lproj/Localizable.strings"
/Users/poupou/Downloads/1.1 2/Apollo.iOS/Resources/es.lproj/Localizable.strings: UTF-8 Unicode c program text, with CRLF, LF line terminators

$ plutil "/Users/poupou/Downloads/1.1 2/Apollo.iOS/Resources/es.lproj/Localizable.strings"
/Users/poupou/Downloads/1.1 2/Apollo.iOS/Resources/es.lproj/Localizable.strings: OK
Comment 11 Sebastien Pouliot 2015-04-20 17:04:57 UTC
On a Mac the `iconv` tool can convert the files

$ iconv -f iso-8859-1 -t utf8 < "Apollo.iOS/Resources/tr.lproj/Localizable.strings" > tr
$ file tr
tr: UTF-8 Unicode c program text
$ plutil tr
tr: OK
Comment 12 Sebastien Pouliot 2015-04-20 17:15:55 UTC
Jon confirmed this to work once he converted the files to UTF8 - only the XVS issue remains (and is tracked on the 2nd bug report).
Comment 13 Jon Goldberger [MSFT] 2015-04-20 17:26:28 UTC
Screencast on how to save a text file with UTF-8 encoding in Visual Studio:

1. Open text file in Visual Studio.

2. Select "Save <path to text file> as..." from the file menu.

3. Click the arrow next to the Save button in the lower right and select "Save with encoding..."

4. Choose to replace the file. 

5. Choose UTF-8 in the dialog that follows.