Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialogs in CacheManager contain hardcoded English strings #1668

Closed
grishka opened this issue Dec 15, 2020 · 1 comment
Closed

Dialogs in CacheManager contain hardcoded English strings #1668

grishka opened this issue Dec 15, 2020 · 1 comment
Assignees
Milestone

Comments

@grishka
Copy link

grishka commented Dec 15, 2020

Issue Type

[ ] Question
[ ] Bug
[x] Improvement
[ ] Build system related
[ ] Performance
[ ] Documentation

Description and/or steps/code to reproduce the problem

CacheManager shows dialogs, and all the user-visible strings are hardcoded and not translatable. For example:

public CacheManagerDialog getDownloadingDialog(final Context pCtx, final CacheManagerTask pTask) {
return new CacheManagerDialog(pCtx, pTask) {
@Override
protected String getUITitle() {
return "Downloading tiles";
}
@Override
public void onTaskFailed(int errors) {
super.onTaskFailed(errors);
Toast.makeText(pCtx, "Loading completed with " + errors + " errors.", Toast.LENGTH_SHORT).show();
}
};
}

I was able to substitute this particular one for a localized string like this, but still...

CacheManager mgr=new CacheManager(OSM.OPENTOPOMAP, new SqliteArchiveTileWriter(tilesDb.getAbsolutePath()), minZoom, maxZoom){
	@Override
	public CacheManagerDialog getDownloadingDialog(Context pCtx, CacheManagerTask pTask){
		return new CacheManagerDialog(pCtx, pTask) {
			@Override
			protected String getUITitle() {
				return getString(R.string.downloading_map);
			}

			@Override
			public void onTaskFailed(int errors) {
				super.onTaskFailed(errors);
				Toast.makeText(pCtx, "Loading completed with " + errors + " errors.", Toast.LENGTH_SHORT).show();
			}
		};
	}
};

It would be nice to move the strings to a strings.xml file so that apps could provide their own translated versions by overriding them in other locales.

Environment

If it's a bug, version(s) of android this affects:

All

Version of osmdroid the issue relates to:

6.1.2

@monsieurtanuki
Copy link
Collaborator

@grishka The good thing is that as you see it's very easy to put your own translation even with the current implementation.

What if someone else would like to put the name of the set of tiles being currently downloaded, like "Downloading map of Italy"? Your improvement suggestion wouldn't work; in that case again you would have to override getUITitle.

My point of view: the current system is flexible enough for all developers' needs. Btw I'm not an expert on strings.xml files - I mean, yes of course I use one per language, but not several files for the same language, with the possible tag collision issues. And as a developer I don't like the idea of retrieving unnecessary data (including translations) from a lib for languages or use-cases I don't need.

That being said, feel free to create a PR for the translation of "Downloading tiles" through strings.xml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants