Константин Константин - 3 months ago 48
Android Question

Libgdx localisation

I want create a Localisation file for my project in Libgdx; however, my code is throwing an error.

My code:

package com.mygdx.mytest;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.utils.I18NBundle;

import java.util.Locale;

public class MyTest extends ApplicationAdapter {

public void create () {
FileHandle baseFileHandle = Gdx.files.internal("i18n/MyBundle");
Locale locale =new Locale("", "", "");
I18NBundle MyBundle = I18NBundle.createBundle(baseFileHandle, locale);

public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);

My error:

I18NBundle MyBundle = I18NBundle.createBundle(baseFileHandle, locale);

Where is my mistake? Please help.


Your code works, but apparently you don't have a bundle. You need to have a file with path:

{project root}/android/assets/i18n/MyBundle.properties

Remember to give a error log.