Skip to content

Commit

Permalink
/i18n/messages endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Jun 9, 2017
1 parent 745493a commit 6d53081
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/main/java/de/metas/ui/web/i18n/I18NRestController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package de.metas.ui.web.i18n;

import java.util.Map;

import org.adempiere.util.Services;
import org.adempiere.util.api.IMsgBL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import de.metas.ui.web.config.WebConfig;
import de.metas.ui.web.session.UserSession;

/*
* #%L
* metasfresh-webui-api
* %%
* Copyright (C) 2017 metas GmbH
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 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 Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/

@RestController
@RequestMapping(I18NRestController.ENDPOINT)
public class I18NRestController
{
public static final String ENDPOINT = WebConfig.ENDPOINT_ROOT + "/i18n";

private static final String AD_MESSAGE_PREFIX = "webui.";

@Autowired
private UserSession userSession;

@GetMapping("/messages")
public Map<String, String> getMessages()
{
return Services.get(IMsgBL.class).getMsgMap(userSession.getAD_Language(), AD_MESSAGE_PREFIX, true /* removePrefix */);
}
}

0 comments on commit 6d53081

Please sign in to comment.