mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
add activity for localizing strings and add menuitem to localizable activities to trigger it. Does nothing yet, including populating itself.
This commit is contained in:
parent
16346beeb1
commit
2494f7b8d4
8 changed files with 210 additions and 33 deletions
|
@ -187,6 +187,9 @@
|
|||
<activity android:name="ChatActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
/>
|
||||
<activity android:name=".loc.LocActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
/>
|
||||
|
||||
<service android:name="RelayService"/>
|
||||
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg x='0px' y='0px' xml:space='preserve' id='Layer_1' height='32px' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' version='1.1' style='enable-background:new 0 0 32 32;' xmlns:cc='http://creativecommons.org/ns#' xmlns:dc='http://purl.org/dc/elements/1.1/' width='32px' xmlns:xlink='http://www.w3.org/1999/xlink'>
|
||||
<metadata><rdf:RDF><cc:Work><dc:subject><rdf:Bag><rdf:li>core</rdf:li></rdf:Bag></dc:subject></cc:Work></rdf:RDF></metadata><path d='M26.498,23.393l-4.055-4.056c-0.357-0.356-1.003-0.322-1.65,0.015l-1.77-1.768c2.305-3.011,2.088-7.334-0.667-10.089
|
||||
c-3-2.999-7.862-2.999-10.862,0c-2.998,3-2.998,7.863,0,10.862c2.756,2.755,7.079,2.973,10.09,0.667l1.769,1.768
|
||||
c-0.337,0.649-0.372,1.295-0.016,1.651l4.056,4.056c0.512,0.512,1.624,0.23,2.48-0.627C26.729,25.016,27.011,23.904,26.498,23.393z
|
||||
M8.637,17.215c-2.368-2.369-2.368-6.21,0-8.578c2.37-2.37,6.207-2.368,8.578,0c2.367,2.368,2.367,6.208,0,8.578
|
||||
C14.844,19.583,11.004,19.583,8.637,17.215z'/>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="120"
|
||||
height="120" xml:space="preserve">
|
||||
<g
|
||||
id="g12"
|
||||
transform="matrix(1.25,0,0,-1.25,0,120)">
|
||||
<g id='g1532'>
|
||||
<g id='g1534'>
|
||||
<g transform='translate(25.91,44.35)' id='g1540'>
|
||||
<path style='fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none' d='M 0,0 C -7.104,7.11 -7.104,18.63 0,25.74 7.109,32.85 18.62,32.84 25.73,25.74 32.84,18.63 32.84,7.114 25.73,0 18.62,-7.104 7.104,-7.104 0,0 M 53.58,-18.53 41.42,-6.365 C 40.35,-5.297 38.41,-5.398 36.47,-6.41 L 31.16,-1.105 C 38.08,7.928 37.42,20.9 29.16,29.16 20.16,38.16 5.573,38.16 -3.427,29.16 -12.42,20.16 -12.42,5.575 -3.427,-3.425 4.841,-11.69 17.81,-12.34 26.84,-5.426 L 32.15,-10.73 C 31.14,-12.68 31.03,-14.61 32.1,-15.68 L 44.27,-27.85 C 45.81,-29.38 49.14,-28.54 51.71,-25.97 54.28,-23.4 55.12,-20.07 53.58,-18.53' id='path1542'/>
|
||||
</g>
|
||||
</g>
|
||||
</g></g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
60
xwords4/android/XWords4/res/layout/loc_main.xml
Normal file
60
xwords4/android/XWords4/res/layout/loc_main.xml
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:custom="http://schemas.android.com/apk/res/org.eehouse.android.xw4"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<!-- Search field -->
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<EditText android:id="@+id/loc_search_field"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
|
||||
<ImageButton android:id="@+id/loc_search_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/search__gen"
|
||||
android:gravity="right"
|
||||
android:layout_weight="0"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- table header -->
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="@string/loc_main_english"
|
||||
/>
|
||||
|
||||
<org.eehouse.android.xw4.loc.LocTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
custom:strid="@string/loc_main_yourlang"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- main list (of pairs loaded dynamically) -->
|
||||
<ListView android:id="@id/android:list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
|
@ -114,6 +114,7 @@
|
|||
|
||||
<!-- Nor is my email address -->
|
||||
<string name="email_author_email">xwords@eehouse.org</string>
|
||||
<string name="loc_main_english">English</string>
|
||||
|
||||
<!-- other -->
|
||||
<string name="default_host">eehouse.org</string>
|
||||
|
|
|
@ -2231,4 +2231,6 @@
|
|||
<string name="slmenu_deselect_all">Unselect all</string>
|
||||
<string name="sel_items_fmt">Selected: %1$d</string>
|
||||
|
||||
<string name="loc_main_yourlang">Your language</string>
|
||||
<string name="loc_menu_xlate">Translate</string>
|
||||
</resources>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2014 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
package org.eehouse.android.xw4.loc;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class LocActivity extends ListActivity {
|
||||
|
||||
private LocDelegate m_dlgt;
|
||||
|
||||
@Override
|
||||
protected void onCreate( Bundle savedInstanceState )
|
||||
{
|
||||
super.onCreate( savedInstanceState );
|
||||
m_dlgt = new LocDelegate( this, savedInstanceState );
|
||||
} // onCreate
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2014 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
package org.eehouse.android.xw4.loc;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.eehouse.android.xw4.DelegateBase;
|
||||
import org.eehouse.android.xw4.R;
|
||||
|
||||
|
||||
public class LocDelegate extends DelegateBase {
|
||||
|
||||
private ListActivity m_activity;
|
||||
|
||||
protected LocDelegate( ListActivity activity, Bundle savedInstanceState )
|
||||
{
|
||||
super( activity, savedInstanceState );
|
||||
m_activity = activity;
|
||||
init( savedInstanceState );
|
||||
}
|
||||
|
||||
private void init( Bundle savedInstanceState )
|
||||
{
|
||||
m_activity.setContentView( R.layout.loc_main );
|
||||
}
|
||||
|
||||
}
|
|
@ -19,9 +19,12 @@
|
|||
|
||||
package org.eehouse.android.xw4.loc;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem.OnMenuItemClickListener;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
@ -54,32 +57,9 @@ public class LocUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static void xlateMenu( Context context, Menu menu )
|
||||
public static void xlateMenu( Activity activity, Menu menu )
|
||||
{
|
||||
int count = menu.size();
|
||||
DbgUtils.logf( "xlateMenu: menu has %d items", count );
|
||||
for ( int ii = 0; ii < count; ++ii ) {
|
||||
MenuItem item = menu.getItem( ii );
|
||||
CharSequence ts = item.getTitle();
|
||||
if ( null != ts ) {
|
||||
String title = ts.toString();
|
||||
DbgUtils.logf( "xlateMenu: %d; %s", ii, title );
|
||||
if ( title.startsWith( LOC_PREFIX ) ) {
|
||||
String asKey = title.substring( LOC_PREFIX.length() );
|
||||
int id = LocIDs.getID( asKey );
|
||||
if ( LocIDs.NOT_FOUND != id ) {
|
||||
asKey = getString( context, id );
|
||||
} else {
|
||||
DbgUtils.logf( "nothing for %s", asKey );
|
||||
}
|
||||
item.setTitle( asKey );
|
||||
}
|
||||
}
|
||||
|
||||
if ( item.hasSubMenu() ) {
|
||||
xlateMenu( context, item.getSubMenu() );
|
||||
}
|
||||
}
|
||||
xlateMenu( activity, menu, 0 );
|
||||
}
|
||||
|
||||
public static String xlateString( Context context, String str )
|
||||
|
@ -118,4 +98,48 @@ public class LocUtils {
|
|||
str = String.format( str, params );
|
||||
return str.toUpperCase();
|
||||
}
|
||||
|
||||
private static void xlateMenu( final Activity activity, Menu menu,
|
||||
int depth )
|
||||
{
|
||||
int count = menu.size();
|
||||
DbgUtils.logf( "xlateMenu: menu has %d items", count );
|
||||
for ( int ii = 0; ii < count; ++ii ) {
|
||||
MenuItem item = menu.getItem( ii );
|
||||
CharSequence ts = item.getTitle();
|
||||
if ( null != ts ) {
|
||||
String title = ts.toString();
|
||||
DbgUtils.logf( "xlateMenu: %d; %s", ii, title );
|
||||
if ( title.startsWith( LOC_PREFIX ) ) {
|
||||
String asKey = title.substring( LOC_PREFIX.length() );
|
||||
int id = LocIDs.getID( asKey );
|
||||
if ( LocIDs.NOT_FOUND != id ) {
|
||||
asKey = getString( activity, id );
|
||||
} else {
|
||||
DbgUtils.logf( "nothing for %s", asKey );
|
||||
}
|
||||
item.setTitle( asKey );
|
||||
}
|
||||
}
|
||||
|
||||
if ( item.hasSubMenu() ) {
|
||||
xlateMenu( activity, item.getSubMenu(), 1 + depth );
|
||||
}
|
||||
}
|
||||
|
||||
// The caller is loc-aware, so add our menu -- at the top level!
|
||||
if ( 0 == depth ) {
|
||||
String title = getString( activity, R.string.loc_menu_xlate );
|
||||
menu.add( title )
|
||||
.setOnMenuItemClickListener( new OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick( MenuItem item ) {
|
||||
Intent intent =
|
||||
new Intent( activity, LocActivity.class );
|
||||
activity.startActivity( intent );
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue