Константин Константин - 29 days ago 12
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 {

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

@Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
}


My error:

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


Where is my mistake? Please help.

Answer

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.

Comments