Bollywood

Hollywood

South

Web-Series

Home
// MUST be defined as this, cannot be proguarded public class TranslateItem implements Serializable { private static final long serialVersionUID = -3101805950698159689L; public String name; public String originValue; public String translatedValue; public TranslateItem(String _n, String _o) { this.name = _n; this.originValue = _o; } public TranslateItem(String _n, String _o, String _t) { this.name = _n; this.originValue = _o; this.translatedValue = _t; } } And, please refer to following code to get all the passed parameters: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ... Intent intent = getIntent(); Bundle bundle = intent.getExtras(); // Target language code like "-de" this.targetLanguageCode = bundle.getString("targetLanguageCode"); // Translated items are also passed, so that we can revise it this.translatedFilePath = bundle.getString("translatedList_file"); this.translatedList = (List) readObjectFromFile(translatedFilePath); // Untranslated items, which are to be translated String path =bundle.getString("untranslatedList_file"); this.untranslatedList = (List) readObjectFromFile(path); // ... } public static Object readObjectFromFile(String filePath) { Object result = null; File file = new File(filePath); ObjectInputStream objIn = null; try { objIn = new ObjectInputStream(new FileInputStream(file)); result = objIn.readObject(); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } finally { closeWithoutThrow(objIn); } return result; } Set Translate Result After the translation, we should return back the result using following code: private void setResult(List stringValues) { Intent intent = new Intent(); intent.putExtra("targetLanguageCode", this.targetLanguageCode); writeObjectToFile(this.translatedFilePath, stringValues); intent.putExtra("translatedList_file", this.translatedFilePath); this.setResult(RESULT_OK, intent); } public static void writeObjectToFile(String filePath, Object obj) { File file = new File(filePath); ObjectOutputStream objOut = null; try { objOut = new ObjectOutputStream(new FileOutputStream(file)); objOut.writeObject(obj); objOut.flush(); } catch (IOException e) { e.printStackTrace(); } finally { closeWithoutThrow(objOut); } } AndroidManifest Requirement In general, we should request permissions like (as we may use online translators): And, to make APK Editor can find the plugin, we should declare the activity like:

 

import "sync var once sync. Once *RoundRobinIndexCounterTypetypo var RoundRobin Index Counter Round Robin Index CounterType struct { mu sync.Mutex V map[string]int len int 1// return the current index and increment index. key will be experiment ID func (counter "RoundRobin Index CounterType) Get Index (key string) int { // Lock so only one goroutine at a time can accesS the map c.v. counter.mu.Lock() defer counter.mu. Unlock() current Idx: counter.v[key] // reset counter if it crosses max length length if nextIdx counter.v[key] + 1; nextIdx > counter.len [ counter. Reset Counter(key) } else { counter.v[key] nextIdx } return currentIdx func (counter *RoundRobin Index CounterType) Reset Counter(key string) { counter.v[key] = 0 } func Initialize Round RobinIndexCounte { once. Do (func() { C Round Robin Index CounterType{v: make(map[string]int), len: 1000} RoundRobinIndexCounter = &c }) J