0

I have this textView

<TextView
            android:id="@+id/author"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/article_image"
            android:layout_marginStart="10dp"
            android:layout_marginTop="5dp"
            android:layout_toEndOf="@+id/cover_details"
            android:maxLines="1"
            android:text="@string/authorBy"
            android:textAlignment="viewStart"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textSize="12sp" />

It simply shows a word By: and it supposed to show translations of that word when app language is changed, while my app is translated fully to another locale, this string still stays on By: and won't get translated word.

one

any suggestion?

Update

Here is how my string files and structure looks like:

two

my strings.xml file

<resources>
    <string name="app_name">ISP</string>
    <string name="navigation_drawer_open">Open navigation drawer</string>
    <string name="navigation_drawer_close">Close navigation drawer</string>
    <string name="nav_header_title">ISP</string>
    <string name="nav_header_subtitle">info@example.com</string>
    <string name="nav_header_desc">Navigation header</string>
    <string name="language_settings">Change Language</string>

    <string name="menu_home">Home</string>
    <string name="menu_gallery">Gallery</string>
    <string name="menu_slideshow">Slideshow</string>
    <string name="menu_our_apps">Our Apps</string>
    <string name="menu_share">Share</string>
    <string name="menu_send">Send</string>
    <string name="title">list title</string>
    <string name="description">list description</string>
    <string name="Image">image</string>
    <string name="image">image</string>
    <string name="category_posts_here">Category posts here</string>
    <string name="title_activity_articles_detail">Articles Detail</string>
    <string name="textViewSample">Sample Text</string>
    <string name="asset_statements" translatable="false">[{ \"include\": \"https://example.com/.well-known/assetlinks.json\" }]</string>
    <string name="title_activity_settings">Settings</string>

    <!-- Preference Titles -->
    <string name="settings_header">Settings</string>

    <!-- Messages Preferences -->
    <string name="select_language">Select Language</string>

    <!-- Sync Preferences -->
    <string name="communicate">Communicate</string>
    <string name="arabic">Arabic</string>
    <string name="Bahasa">Bahasa</string>
    <string name="persian">Persian</string>
    <string name="english">English</string>
    <string name="authorBy">By:</string>
</resources>
mafortis
  • 6,750
  • 23
  • 130
  • 288
  • 1
    Have you tried to isolate this issue in a separate app with this `By:` string being the only string to translate? Just a suggestion... – drishit96 Feb 16 '20 at 16:04

1 Answers1

0

Ahlan! Looks like your alternative language is Arabic?

If you you may need to enable Right to Left support, in your AndroidManifest file.

https://developer.android.com/guide/topics/manifest/application-element#supportsrtl

Declares whether your application is willing to support right-to-left (RTL) layouts. If set to true and targetSdkVersion is set to 17 or higher, various RTL APIs will be activated and used by the system so your app can display RTL layouts. If set to false or if targetSdkVersion is set to 16 or lower, the RTL APIs will be ignored or will have no effect and your app will behave the same regardless of the layout direction associated to the user's Locale choice (your layouts will always be left-to-right).

The default value of this attribute is false.

i.e.

<application
   android:supportsRtl="true"
   ...
Blundell
  • 75,855
  • 30
  • 208
  • 233
  • hi there, thanks for the answer, but as i mentioned my app is translating fully with no issue except this string. the only part in my app that doesn't translate is the `by` string. i am using api 19 and all those settings you've mentioned are set (app working ok, just this string doesn't return translated word) – mafortis Feb 16 '20 at 15:38
  • Oh that is strange! You should share the strings.xml files from your app in your question, and maybe a screenshot of your resources folder for ppl to investigate – Blundell Feb 16 '20 at 19:17
  • Ok so we can now see the EN strings file xml, what about `authorBy` in the arabic strings.xml? – Blundell Feb 17 '20 at 08:21
  • `بواسطة:` you can see the string values from my first screenshot in question i guess – mafortis Feb 17 '20 at 10:11
  • I trust the viewing of the file more than the views the tools give :-). Why do you have a Strings.xml under version 21? is that taking precendence – Blundell Feb 17 '20 at 10:49
  • :) , version 21 file was created since first time i created this app (or maybe after merging to androidX) either way it has similar content as `strings.xml` and about second question: idk – mafortis Feb 17 '20 at 10:57
  • should i delete it? – mafortis Feb 17 '20 at 10:58
  • sure delete it :-) (if you don't have any use for Strings that are specific to newer versions of Android) – Blundell Feb 17 '20 at 10:58
  • nope :/ that didn't fix it. maybe not bad to mention: if in preview mode i change lang it does show string translation but in simulator and real device no. – mafortis Feb 17 '20 at 11:02
  • add your strings.xml for ar to the question. Remove the `textAlignment` see if that fixes it. Remove the `textAppearance` see if that fixes it. Keep removing stuff till you have the smallest amount of code that reproduces the problem – Blundell Feb 17 '20 at 17:21
  • it's very very strange thing can't be fixed yet. – mafortis Feb 18 '20 at 01:33