What does transform_apply(rotation = True) do?

About transform_apply(rotation = True) The documentation says: “Apply the object’s transformation to its data”. But this is not very specific.

-“The object’s transformation”. It’s global or local transformation?
-“its data”. Which data? It’s transform? So it applies it’s own transform to it’s own transform? Of course not. Which data then? The transform supplied? But you can’t supply a transform to the function.

I want to set the rotation of one object to the rotation of another object. Normally this would be done by:
Object->Transform->Align to Transform Orientation
But I don’t want to rotate the object itself, but just the local coordinate system. This shouldn’t be too hard to do.

First use
bpy.ops.transform.transform(mode=‘ALIGN’) # same as Align to Transform Orientation
to align the object with another object. Then set the mesh rotation to the current rotation. Then rotate the object back to it’s original rotation.

It seems that transform_apply(rotation = True) can rotate the mesh and keep the coordinate system the same and can thus be useful for what I want to do. But thanks to Blender’s excellent documentation I have no clue how to use it.

Any help?