Setting up multiple category listing pages on site with multiple locales
The reason it's not working is that domain.com/people/foo/practices/categoryA is not a match for the Category group's URI settings. Only urls that match people/practices/{slug} are going to have that category variable defined.

And this code:

{% if category is defined %}
    {% set entry = category %}
{% endif %}


... won't define an entry if there's no category defined.

If your People structure is a flat list (no nested children), you could create a URL rules like this:

'people/&lt;person:{slug}&gt;/practices/&lt;category:{slug}&gt;' =&gt; [
    'template' =&gt; 'test/4'
],


That would take a URI like domain.com/people/foo/practices/categoryA and use the  people/_practices template and populate variables for person and category.

{{ person }}    {# foo #}
{{ category }}  {# categoryA #}


Then you could make an category query like this:

{% set cat = craft.categories().group('practices').slug(category).one() %}

{{ cat.title }}


But personally, I've found it easier to use query strings to filter a list instead of URL segments. You could possibly use a URL like this:

domain.com/people/foo?practice=categroyA

or...

domain.com/people/foo/practice?cat=categroyA

or even...

domain.com/people/practice?person=foo&amp;cat=categroyA

Whichever works the most logically for your use case. Then use craft.app.request to pull the "categoryA" string from the URL:

{% set categorySlug = craft.app.request.getQueryParam('cat') ?? null %}

{% if categorySlug %}
  {{ categorySlug }}   {# "categoryA" #}
{% endif %}


Then use the categorySlug string in an entry or category query:

{% set cat = craft.categories().group('practices').slug(category).one() %}


Update

It's important to note, if you want a variable you set to be available in a layout template ({% extend %} tag), you need to define it outside of a {% block %} tag.

{% extends "_layouts/index" %}

{% set categorySlug = craft.app.request.getQueryParam('cat') ?? null %}

{% block content %}
  Content...
{% endblock %}


The categorySlug variable should now be available in the _layouts/index template context as well.

&lt;body&gt;
  &lt;div class="language-switcher"&gt;
    {% if categorySlug is defined %}
      Yes it is!
    {% endif %}        
  &lt;/div&gt;

  {% block content %}
  {% endblock %}
&lt;/body&gt;