pwlin / cordova-plugin-file-opener2

A File Opener Plugin for Cordova
MIT License
314 stars 583 forks source link

Text Open file in always localized in english (Android) #331

Open JaviManteiga opened 1 year ago

JaviManteiga commented 1 year ago

I'm working on a Ionic + cordova project and I use this plugin to open PDFs in Android (with the method showOpenWithDialog of the awesome-cordova-plugins) but when the dialog opens to choose which app you want to open the file with, the header text (Open file in) is always in english. However the cancel button works as expected. I've seen this issue regarding the same problem in iOS but the solution is not applicable to Android. Is this a bug? am I missing something?

Thanks in advance

JaviManteiga commented 1 year ago

I've been investigating and I found that this text is hardcoded in the FileOpener2.java:141. The fastest "solution" would be to fork the plugin and change the text but that doesn't solve the case where the app is multilanguage. Any ideas on how this text could be sent translated in the current language from the app to the plugin without breaking the ionic interface?

shnist commented 1 year ago

hi @JaviManteiga. Thank you for raising this issue. Unfortunately there are no plans to support other languages with this plugin, but we would be happy to accept a PR.

bha2020 commented 4 months ago

@JaviManteiga Can you provide me your solution code to open pdf file in android using ionic ? try { this.fileOpener.open(this.pdfPath.toString(), 'application/pdf') .then(() => console.log('File opened successfully')) .catch(error => { console.error('Error opening file:'); for (const prop in error) { console.error(prop + ':', error[prop]); } }); } catch (error) { console.error('Error opening document:', error); } } this is my code but its not opening dialog to open pdf

JaviManteiga commented 4 months ago

@JaviManteiga Can you provide me your solution code to open pdf file in android using ionic ? try { this.fileOpener.open(this.pdfPath.toString(), 'application/pdf') .then(() => console.log('File opened successfully')) .catch(error => { console.error('Error opening file:'); for (const prop in error) { console.error(prop + ':', error[prop]); } }); } catch (error) { console.error('Error opening document:', error); } } this is my code but its not opening dialog to open pdf

I'm not using that function. My code is similar to the example in the docs

https://github.com/pwlin/cordova-plugin-file-opener2?tab=readme-ov-file#quick-example