ISALIN

- 4 mins

This Spring Boot library simplifies and streamlines the usage of the Google Translate API, reducing boilerplate code and providing a more convenient integration.

isalin-version isalin-java-comp isalin-spring-comp isalin-license CodeQL Dependency Review

FEATURES


SETUP

To start using Isalin library, you need to setup first your Google Authentication credentials.

Apache Maven

<dependency>
    <groupId>com.acltabontabon</groupId>
    <artifactId>isalin</artifactId>
    <version>1.0.2</version>
</dependency>

Gradle

implementation group: 'com.acltabontabon', name: 'isalin', version: '1.0.2'

USAGE

Single text translation

@Translate(from = Language.ENGLISH, to = Language.FILIPINO)
public String getGreetings() {
  return "Hello world!";
}

Single text translation with auto detection of source language

@Translate(to = Language.FILIPINO)
public String getGreeting() {
  return "Hello world!";
}

Single text translation within a custom object

@Translate(value = "$.body.content", from = Language.ENGLISH, to = Language.FILIPINO)
public CustomMessage getGreeting() {
  CustomMessage msg = new CustomMessage();
  msg.setSource("Tarzan");
  msg.setBody(new Content("Welcome to the jungle!"));

  return msg;
}

Multiple text translation

@Translate(from = Language.ENGLISH, to = Language.FILIPINO)
public List<String> getGreetings() {
  return List.of("Hello!", "Hi");
}

Single file translation

@Translate(from = Language.ENGLISH, to = Language.FILIPINO)
public File getDocument() {
  return new File("/path/to/my/file.pdf");
}

Note Supported file formats: .doc, .docx, .pdf, .ppt, .pptx, .xls, .xlsx

Multiple file translation

@Translate(from = Language.ENGLISH, to = Language.FILIPINO)
public List<File> getDocuments() {
  return List.of(new File("/path/to/my/file.pdf"), new File("/path/to/my/file2.pdf"));
}

Inline translation

@Autowired
private IsalinService isalinService;
    
private void translate() {
  String text  = isalinService.translateText("Hello", Language.ENGLISH, Language.FILIPINO);
  List<String> texts  = isalinService.translateTexts(List.of("Hi","Hello"), Language.ENGLISH, Language.FILIPINO);
  
  File doc  = isalinService.translateDocument("/path/to/my/file.pdf", Language.ENGLISH, Language.FILIPINO);
  List<File> docs  = isalinService.translateDocuments(List.of("/path/file.ppt","/path/file.pdf"), Language.ENGLISH, Language.FILIPINO);
  
  // auto detection of source language
  String text2  = isalinService.translateText("Hello", Language.ANY, Language.FILIPINO);
  File doc2  = isalinService.translateDocument("/path/to/my/file.pdf", Language.ANY, Language.FILIPINO);
}

Request / Issues

If you have feature requests or encounter any issues, please open a ticket.

Alvin Cris Tabontabon

Alvin Cris Tabontabon

An Asian man who codes to eat noodles