org.nuiton.i18n.plugin.bundle.csv.I18nBundleModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of i18n-maven-plugin Show documentation
Show all versions of i18n-maven-plugin Show documentation
Maven plugin to deal with i18n stuff in a project, mainly base on the
nuiton-i18n api (but not only).
The newest version!
package org.nuiton.i18n.plugin.bundle.csv;
/*
* #%L
* I18n :: Maven Plugin
* %%
* Copyright (C) 2007 - 2014 CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import org.nuiton.csv.ValueGetterSetter;
import org.nuiton.csv.ext.AbstractImportExportModel;
import java.util.Locale;
/**
* Created on 7/26/14.
*
* @author Tony Chemit - [email protected]
* @since 3.3
*/
public class I18nBundleModel extends AbstractImportExportModel {
public I18nBundleModel(char separator, Locale[] locales) {
super(separator);
newMandatoryColumn("key");
newColumnForExport("key");
for (final Locale locale : locales) {
ValueGetterSetter getterSetter = new ValueGetterSetter() {
@Override
public String get(I18nBundleModelRow row) throws Exception {
return row.getLocaleValue(locale);
}
@Override
public void set(I18nBundleModelRow row, String s) throws Exception {
row.setLocaleValue(locale, s);
}
};
newColumnForExport(locale.getCountry(), getterSetter);
newMandatoryColumn(locale.getCountry(), getterSetter);
}
}
@Override
public I18nBundleModelRow newEmptyInstance() {
return new I18nBundleModelRow();
}
}