I try to modify my app to read from a MySQL-DB the content with loacalized language as a separate column.
The easist way (dirty workaround) I image, is to change the statement @SerializedName("name") to @SerializedName("name_de") with an if-else.
if(Locale.getDefault().getDisplayName().equals("de")){
@SerializedName("name_de")
}else
{
@SerializedName("name")
}
But where and how to put it in the code?
import android.content.res.Resources;
import android.os.Build;
import android.util.Log;
import java.util.*;
import com.google.gson.annotations.SerializedName;
import com.xxxxxxx.storefinder.R;
import java.util.Locale;
public class Category {
public Category(int id, String name) {
this.id = id;
this.name = name;
}
// @SerializedName("name_de")
// public String name ="";
@SerializedName("name")
public String name = "";
@SerializedName("id")
public int id;
}```
Sorry for this noob question.
I just don't understand the underlying concept and just need to localize this app, the easy way
kr
Daniel
Aucun commentaire:
Enregistrer un commentaire