Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to reword strings of bottomNavigationMenu #12

Closed
ashu5398 opened this issue Nov 7, 2020 · 5 comments
Closed

Unable to reword strings of bottomNavigationMenu #12

ashu5398 opened this issue Nov 7, 2020 · 5 comments

Comments

@ashu5398
Copy link
Contributor

ashu5398 commented Nov 7, 2020

Hi, I am unable to change the strings inflated in bottom Navigation Menu. Here is my code of bottomNavigationMenu. Is there anything I am missing on my end?

<com.google.android.material.bottomnavigation.BottomNavigationView            
            android:id="@+id/bottomNav"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            app:labelVisibilityMode="labeled"
            android:background="#fff"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:menu="@menu/menu_home" />
@B3nedikt
Copy link
Owner

B3nedikt commented Nov 7, 2020

The BottomNavigtaionView is supported out of the box, as this lib contains a ViewTransfomer for it. I just integrated a BottomNavigationView into my sample app and everything works fine there.

Your code above looks correct, you may try to recreate the issue by forking my sample app and integrate your BottomNavigationView in the same way as in your real app. If this does not recreate the issue it may be due to something specific for your app. It may also depend on some specific version of the material lib or other libs used in your project.

@ashu5398
Copy link
Contributor Author

ashu5398 commented Nov 8, 2020

Oh Thanks!! I got the issue, I have not defined the id's for menu items. Also Just want to know one thing, the same way we are transforming the BottomNavigationMenu items, can we transform the menu items of the toolbar/support toolbar, so that strings of popup menu also got translated easily. As PopupMenu does not extends View we can not make its transformer directly, Or is there any other way to update popup menu strings?

@B3nedikt
Copy link
Owner

B3nedikt commented Nov 8, 2020

You're welcome :) Yes, it should work the same way with Toolbar/support Toolbar as with the BottomNavigationItems.

Basically something like this in the ToolbarViewTransformer:

    override fun Toolbar.transform(attrs: Map<String, Int>) {
        attrs.forEach { entry ->
            when (entry.key) {
                ATTRIBUTE_TITLE, ATTRIBUTE_ANDROID_TITLE -> updateTexts(entry.value, this::setTitle)
                ATTRIBUTE_SUBTITLE, ATTRIBUTE_ANDROID_SUBTITLE -> updateTexts(entry.value, this::setSubtitle)
                SOME_ATTRIBUTE -> menu.getItem(...).setTitle()
            }
        }
    }

I don't have the time to look into this at the moment, but maybe in the next weeks, this would definitely be a good improvement for the lib. If you want the feature now you can implement it though and create a PR :)

@ashu5398
Copy link
Contributor Author

ashu5398 commented Nov 9, 2020

PR added with the update: #14 :)

@ashu5398 ashu5398 closed this as completed Nov 9, 2020
@B3nedikt
Copy link
Owner

B3nedikt commented Nov 9, 2020

@ashu5398 Released as version 2.1.0, thanks for the contribution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants