This section will show you how to internationalize activities in Social via the following topics:
* [Internationalize an activity|#SOCref.Developers_References.How_to_create_i18n_activities.I18n_activities]
* [Get an internationalized message |#SOCref.Developers_References.How_to_create_i18n_activities.Get_i18n_message]

{docbook}
<para xml:id="SOCref.Developers_References.How_to_create_i18n_activities.I18n_activities">
<citetitle>
<emphasis role="bold">
Internationalize an activity
</emphasis>
</citetitle>
</para>
{docbook}
In the previous versions, Social had hard-coded messages for activities, such as
creating spaces, granting the "manager" role to a member, sending connection request to another user, updating a user's profile/avatar, and more.
And now, to internationalize these types of messages, you can use resource bundles and _I18NActivityProcessor_.

For example, to internationalize an activity of the *exosocial\:spaces* type that is for space creation message, do as follows:

*1.* Set _titleId_ for the _ExoSocialActivity_ model.
{code}
ActivityType = exosocial:spaces, titleId = space_created, resource bundle key file: locale.social.Core, and associated message bundle key:SpaceActivityPublisher.space_created
{code}
The _titleId_ is used to map with a corresponding message bundle key via the configuration.

*Sample code for saving internationalized activities*

{code:java}public void saveActivity() {
    ActivityManager activityManager = (ActivityManager) PortalContainer.getInstance().getComponentInstanceOfType(ActivityManager.class);
    ExoSocialActivity activity = new ExoSocialActivityImpl();
    activity.setType("exosocial:spaces"); // the associated activity type
    activity.setTitleId("space_created"); // to indicate this is i18n activity type
    // this is the fallback activity title when it's not i18n-ized.
    // This must be required.
    activity.setTitle("Test was created by @john");
    //template params are used to for compound messages
    // with message bundle key:
    // SpaceActivityPublisher.space_created={0} was created by {1}.
    Map<String, String> templateParams = new LinkedHashMap<String, String>();
    templateParams.put("space_name", "Test");
    templateParams.put("user", "@john");

    //must indicate this param if you want a template value is processed by activity processors
    templateParams.put(BaseActivityProcessorPlugin.TEMPLATE_PARAM_TO_PROCESS, "user");
    activity.setTemplateParams(templateParams);

    //gets the target stream to post

    IdentityManager identityManager = (IdentityManager) PortalContainer.getInstance().getComponentInstanceOfType(IdentityManager.class);
    Identity spaceIdentity = identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME, "test", false);

    activity.setUserId(spaceIdentity.getId()); // the actor is the space identity

    //posts this activity to space's activity stream
    activityManager.saveActivityNoReturn(spaceIdentity, activity);
}{code}

The sample code above is enough for creating an internationalized activity that will be displayed on the space activity stream portlet after
all the configurations below are done. The returned result will be displayed in English like this: "_Test was created by <a href="link-to-john-profile">John</a>_".

*2.* Register the _ActivityResourceBundlePlugin_ plugin to the _I18NActivityProcessor_ component in the configuration file as the example below:
{code:xml}<external-component-plugins>
    <target-component>org.exoplatform.social.core.processor.I18NActivityProcessor</target-component>
    <component-plugin>
      <name>exosocial:spaces</name> <!-- activity type -->
      <set-method>addActivityResourceBundlePlugin</set-method>
      <type>org.exoplatform.social.core.processor.ActivityResourceBundlePlugin</type>
      <init-params>
        <object-param>
          <name>locale.social.Core</name> <!-- resource bundle key file -->
          <description>activity key type resource bundle mapping for exosocial:spaces</description>
          <object type="org.exoplatform.social.core.processor.ActivityResourceBundlePlugin">
            <field name="activityKeyTypeMapping">
              <map type="java.util.HashMap">
                <entry>
                  <key><string>space_created</string></key>
                  <value><string>SpaceActivityPublisher.space_created</string></value>
                </entry>
              </map>
            </field>
          </object>
        </object-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>{code}

If the resource bundle message is compound, you must provide _templateParams_. The argument number will be counted as it appears on the map.
For example:
{code}templateParams = {"key1": "value1", "key2": "value2"} => arguments = ["value1", "value2"]{code}

{note}
To reserve this order, _LinkedHashMap_ must be used to create _templateParams_ instead of _HashMap_.
{note}

*3.* Register an external resource bundle for that activity type to get an associated resource bundle as follow:
{code:xml}<external-component-plugins>
    <target-component>org.exoplatform.services.resources.ResourceBundleService</target-component>
    <component-plugin>
      <name>Social Core Component Resource Bundle</name>
      <set-method>addResourceBundle</set-method>
      <type>org.exoplatform.services.resources.impl.BaseResourceBundlePlugin</type>
      <init-params>
        <values-param>
          <name>classpath.resources</name>
          <description>The resources that start with the following package name should be loaded from file system</description>
          <value>locale.social.Core</value>
        </values-param>
        <values-param>
          <name>portal.resource.names</name>
          <description>The resources that start with the following package name should be loaded from file system</description>
          <value>locale.social.Core</value>
        </values-param>
      </init-params>
    </component-plugin>
</external-component-plugins>{code}


{docbook}
<para xml:id="SOCref.Developers_References.How_to_create_i18n_activities.Get_i18n_message">
<citetitle>
<emphasis role="bold">
Get an internationalized message
</emphasis>
</citetitle>
</para>
{docbook}

* If you do not have registered UI activity plugins, your activity messages will be internationalized and displayed by the default UI activity.

* If you have registered ui activity plugins, you just need to display _activity.getTitle()_ as it is already internationalized by _BaseUIActivity_.

* In other cases, base on a provided locale as the code below:
{code:java}I18NActivityProcessor i18NActivityProcessor = (I18NActivityProcessor) PortalContainer.getInstance().getComponentInstanceOfType(I18NActivityProcessor.class);
ExoSocialActivity processedActivity =  i18NActivityProcessor.process(unprocessedActivity, chosenLocale);{code}



